From 561bcd28262a3c81acd6023786c3dafa72caf73b Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 7 Oct 2016 17:44:22 +0200 Subject: [PATCH 01/27] distance: Implement Euclidean, Manhattan and Jaccard distances --- Orange/distance/__init__.py | 267 +- Orange/distance/_distance.c | 26154 +++++++++++++++++++++++ Orange/distance/_distance.pyx | 357 + Orange/distance/distances.md | 158 + Orange/distance/setup.py | 22 + Orange/distance/tests/test_distance.py | 754 + Orange/setup.py | 1 + Orange/statistics/util.py | 32 +- Orange/tests/test_distances.py | 4 +- 9 files changed, 27687 insertions(+), 62 deletions(-) create mode 100644 Orange/distance/_distance.c create mode 100644 Orange/distance/_distance.pyx create mode 100644 Orange/distance/distances.md create mode 100644 Orange/distance/setup.py create mode 100644 Orange/distance/tests/test_distance.py diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 17973c03a79..d02855e1ec5 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -5,8 +5,10 @@ from Orange import data from Orange.misc import DistMatrix from Orange.preprocess import SklImpute +from Orange.distance import _distance +from Orange.statistics import util -__all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', 'SpearmanR', +__all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', '`SpearmanR', 'SpearmanRAbsolute', 'PearsonR', 'PearsonRAbsolute', 'Mahalanobis', 'MahalanobisDistance'] @@ -15,13 +17,7 @@ def _preprocess(table): """Remove categorical attributes and impute missing values.""" if not len(table): return table - new_domain = data.Domain( - [a for a in table.domain.attributes if a.is_continuous], - table.domain.class_vars, - table.domain.metas) - new_data = table.transform(new_domain) - new_data = SklImpute()(new_data) - return new_data + return SklImpute()(table) def _orange_to_numpy(x): @@ -39,63 +35,230 @@ def _orange_to_numpy(x): class Distance: - def __call__(self, e1, e2=None, axis=1, impute=False): - """ - :param e1: input data instances, we calculate distances between all - pairs - :type e1: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param e2: optional second argument for data instances if provided, - distances between each pair, where first item is from e1 and - second is from e2, are calculated - :type e2: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param axis: if axis=1 we calculate distances between rows, if axis=0 - we calculate distances between columns - :type axis: int - :param impute: if impute=True all NaN values in matrix are replaced - with 0 - :type impute: bool - :return: the matrix with distances between given examples - :rtype: :class:`Orange.misc.distmatrix.DistMatrix` - """ - raise NotImplementedError( - 'Distance is an abstract class and should not be used directly.') + def __new__(cls, e1=None, e2=None, axis=1, **kwargs): + self = super().__new__(cls) + self.axis = axis + # Ugly, but needed for backwards compatibility hack below, to allow + # setting parameters like 'normalize' + self.__dict__.update(**kwargs) + if e1 is None: + return self + # Backwards compatibility with SKL-based instances + model = self.fit(e1) + return model(e1, e2) + + def fit(self, e1): + pass + + +class DistanceModel: + def __init__(self, axis, impute=False): + self.axis = axis + self.impute = impute -class SklDistance(Distance): - """Generic scikit-learn distance.""" - def __init__(self, metric, name, supports_sparse): + def __call__(self, e1, e2=None): """ + If e2 is omitted, calculate distances between all rows (axis=1) or + columns (axis=2) of e1. If e2 is present, calculate distances between + all pairs if rows from e1 and e2. + Args: - metric: The metric to be used for distance calculation - name (str): Name of the distance - supports_sparse (boolean): Whether this metric works on sparse data - or not. + e1 (Orange.data.Table or Orange.data.RowInstance or numpy.ndarray): + input data + e2 (Orange.data.Table or Orange.data.RowInstance or numpy.ndarray): + secondary data + Returns: + A distance matrix (Orange.misc.distmatrix.DistMatrix) """ - self.metric = metric - self.name = name - self.supports_sparse = supports_sparse + if self.axis == 0 and e2 is not None: + raise ValueError("Two tables cannot be compared by columns") - def __call__(self, e1, e2=None, axis=1, impute=False): x1 = _orange_to_numpy(e1) x2 = _orange_to_numpy(e2) - if axis == 0: - x1 = x1.T - if x2 is not None: - x2 = x2.T - dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric=self.metric) + dist = self.compute_distances(x1, x2) if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, axis) + dist = DistMatrix(dist, e1, e2, self.axis) else: dist = DistMatrix(dist) return dist -Euclidean = SklDistance('euclidean', 'Euclidean', True) -Manhattan = SklDistance('manhattan', 'Manhattan', True) -Cosine = SklDistance('cosine', 'Cosine', True) -Jaccard = SklDistance('jaccard', 'Jaccard', False) + def compute_distances(self, x1, x2): + pass + + +class FittedDistanceModel(DistanceModel): + def __init__(self, attributes, axis, impute=False, fit_params=None): + super().__init__(axis, impute) + self.attributes = attributes + self.fit_params = fit_params + + def __call__(self, e1, e2=None): + if e1.domain.attributes != self.attributes or \ + e2 is not None and e2.domain.attributes != self.attributes: + raise ValueError("mismatching domains") + return super().__call__(e1, e2) + + def compute_distances(self, x1, x2=None): + if self.axis == 0: + return self.distance_by_cols(x1, self.fit_params) + else: + return self.distance_by_rows( + x1, x2 if x2 is not None else x1, self.fit_params) + + +class FittedDistance(Distance): + ModelType = None #: Option[FittedDistanceModel] + + def fit(self, data): + attributes = data.domain.attributes + x = _orange_to_numpy(data) + n_vals = np.fromiter( + (len(attr.values) if attr.is_discrete else 0 + for attr in attributes), + dtype=np.int32, count=len(attributes)) + fit_params = [self.fit_cols, self.fit_rows][self.axis](x, n_vals) + # pylint: disable=not-callable + return self.ModelType(attributes, axis=self.axis, fit_params=fit_params) + + +class EuclideanModel(FittedDistanceModel): + name = "Euclidean" + supports_sparse = False + distance_by_cols = _distance.euclidean_cols + distance_by_rows = _distance.euclidean_rows + + +class Euclidean(FittedDistance): + ModelType = EuclideanModel + + def __new__(cls, *args, **kwargs): + kwargs.setdefault("normalize", False) + return super().__new__(cls, *args, **kwargs) + + def fit_rows(self, x, n_vals): + n_cols = len(n_vals) + n_bins = max(n_vals) + means = np.zeros(n_cols, dtype=float) + vars = np.empty(n_cols, dtype=float) + dist_missing = np.zeros((n_cols, n_bins), dtype=float) + dist_missing2 = np.zeros(n_cols, dtype=float) + + for col in range(n_cols): + column = x[:, col] + if n_vals[col]: + vars[col] = -1 + dist_missing[col] = util.bincount(column, minlength=n_bins)[0] + dist_missing[col] /= max(1, sum(dist_missing[col])) + dist_missing2[col] = 1 - np.sum(dist_missing[col] ** 2) + dist_missing[col] = 1 - dist_missing[col] + elif np.isnan(column).all(): # avoid warnings in nanmean and nanvar + vars[col] = -2 + else: + means[col] = util.nanmean(column) + vars[col] = util.nanvar(column) + if vars[col] == 0: + vars[col] = -2 + if self.normalize: + dist_missing2[col] = 1 + else: + dist_missing2[col] = 2 * vars[col] + if np.isnan(dist_missing2[col]): + dist_missing2[col] = 0 + + return dict(means=means, vars=vars, + dist_missing=dist_missing, dist_missing2=dist_missing2, + normalize=int(self.normalize)) + + def fit_cols(self, x, n_vals): + if any(n_vals): + raise ValueError( + "columns with discrete values are not commensurate") + means = np.nanmean(x, axis=0) + vars = np.nanvar(x, axis=0) + if np.isnan(vars).any() or not vars.all(): + raise ValueError("some columns are constant or have no values") + return dict(means=means, vars=vars, normalize=int(self.normalize)) + + +class ManhattanModel(FittedDistanceModel): + supports_sparse = False + distance_by_cols = _distance.manhattan_cols + distance_by_rows = _distance.manhattan_rows + + +class Manhattan(FittedDistance): + ModelType = ManhattanModel + name = "Manhattan" + + def __new__(cls, *args, **kwargs): + kwargs.setdefault("normalize", False) + return super().__new__(cls, *args, **kwargs) + + def fit_rows(self, x, n_vals): + n_cols = len(n_vals) + n_bins = max(n_vals) + + medians = np.zeros(n_cols) + mads = np.zeros(n_cols) + dist_missing = np.zeros((n_cols, max(n_vals))) + dist_missing2 = np.zeros(n_cols) + for col in range(n_cols): + column = x[:, col] + if n_vals[col]: + mads[col] = -1 + dist_missing[col] = util.bincount(column, minlength=n_bins)[0] + dist_missing[col] /= max(1, sum(dist_missing[col])) + dist_missing2[col] = 1 - np.sum(dist_missing[col] ** 2) + dist_missing[col] = 1 - dist_missing[col] + elif np.isnan(column).all(): # avoid warnings in nanmedian + mads[col] = -2 + else: + medians[col] = np.nanmedian(column) + mads[col] = np.nanmedian(np.abs(column - medians[col])) + if mads[col] == 0: + mads[col] = -2 + if self.normalize: + dist_missing2[col] = 1 + else: + dist_missing2[col] = 2 * mads[col] + return dict(medians=medians, mads=mads, + dist_missing=dist_missing, dist_missing2=dist_missing2, + normalize=int(self.normalize)) + + def fit_cols(self, x, n_vals): + if any(n_vals): + raise ValueError( + "columns with discrete values are not commensurate") + medians = np.nanmedian(x, axis=0) + mads = np.nanmedian(np.abs(x - medians), axis=0) + if np.isnan(mads).any() or not mads.all(): + raise ValueError( + "some columns have zero absolute distance from median, " + "or no values") + return dict(medians=medians, mads=mads, normalize=int(self.normalize)) + + +class JaccardModel(FittedDistanceModel): + supports_sparse = False + distance_by_cols = _distance.jaccard_cols + distance_by_rows = _distance.jaccard_rows + + +class Jaccard(FittedDistance): + ModelType = JaccardModel + name = "Jaccard" + fit_rows = fit_cols = _distance.fit_jaccard + + +class CosineModel(EuclideanModel): + def compute_distances(self, x1, x2=None): + return 1 - np.cos(1 - super().compute_distances(x1, x2)) + + +class Cosine(Euclidean): + ModelType = CosineModel + name = "Cosine" class SpearmanDistance(Distance): diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c new file mode 100644 index 00000000000..9d1c7bbd99b --- /dev/null +++ b/Orange/distance/_distance.c @@ -0,0 +1,26154 @@ +/* Generated by Cython 0.24.1 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. +#else +#define CYTHON_ABI "0_24_1" +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 + #define CYTHON_USE_PYLONG_INTERNALS 1 +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if PY_VERSION_HEX >= 0x030500B1 +#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods +#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) +#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; +} __Pyx_PyAsyncMethodsStruct; +#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) +#else +#define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + +#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 + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__Orange__distance___distance +#define __PYX_HAVE_API__Orange__distance___distance +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "numpy/npy_math.h" +#include "math.h" +#include "pythread.h" +#include "pystate.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) && defined (_M_X64) + #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#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 (size_t)(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_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +/* None.proto */ +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "Orange/distance/_distance.pyx", + "__init__.pxd", + "stringsource", + "type.pxd", +}; +/* MemviewSliceStruct.proto */ +struct __pyx_memoryview_obj; +typedef struct { + struct __pyx_memoryview_obj *memview; + char *data; + Py_ssize_t shape[8]; + Py_ssize_t strides[8]; + Py_ssize_t suboffsets[8]; +} __Pyx_memviewslice; + +/* BufferFormatStructs.proto */ +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; + struct __Pyx_StructField_* fields; + size_t size; + size_t arraysize[8]; + int ndim; + char typegroup; + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + +/* Atomics.proto */ +#include +#ifndef CYTHON_ATOMICS + #define CYTHON_ATOMICS 1 +#endif +#define __pyx_atomic_int_type int +#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\ + (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\ + !defined(__i386__) + #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1) + #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1) + #ifdef __PYX_DEBUG_ATOMICS + #warning "Using GNU atomics" + #endif +#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0 + #include + #undef __pyx_atomic_int_type + #define __pyx_atomic_int_type LONG + #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value) + #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value) + #ifdef __PYX_DEBUG_ATOMICS + #pragma message ("Using MSVC atomics") + #endif +#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0 + #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value) + #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value) + #ifdef __PYX_DEBUG_ATOMICS + #warning "Using Intel atomics" + #endif +#else + #undef CYTHON_ATOMICS + #define CYTHON_ATOMICS 0 + #ifdef __PYX_DEBUG_ATOMICS + #warning "Not using atomics" + #endif +#endif +typedef volatile __pyx_atomic_int_type __pyx_atomic_int; +#if CYTHON_ATOMICS + #define __pyx_add_acquisition_count(memview)\ + __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) + #define __pyx_sub_acquisition_count(memview)\ + __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) +#else + #define __pyx_add_acquisition_count(memview)\ + __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) + #define __pyx_sub_acquisition_count(memview)\ + __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) +#endif + + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":725 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":726 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":727 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":728 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":732 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":733 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":734 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":735 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":739 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":740 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":749 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":750 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":751 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":753 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":754 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":755 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":757 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":758 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":760 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":761 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":762 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; +/* None.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +/* None.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_array_obj; +struct __pyx_MemviewEnum_obj; +struct __pyx_memoryview_obj; +struct __pyx_memoryviewslice_obj; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":764 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":765 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":766 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":768 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; + +/* "View.MemoryView":103 + * + * @cname("__pyx_array") + * cdef class array: # <<<<<<<<<<<<<< + * + * cdef: + */ +struct __pyx_array_obj { + PyObject_HEAD + struct __pyx_vtabstruct_array *__pyx_vtab; + char *data; + Py_ssize_t len; + char *format; + int ndim; + Py_ssize_t *_shape; + Py_ssize_t *_strides; + Py_ssize_t itemsize; + PyObject *mode; + PyObject *_format; + void (*callback_free_data)(void *); + int free_data; + int dtype_is_object; +}; + + +/* "View.MemoryView":275 + * + * @cname('__pyx_MemviewEnum') + * cdef class Enum(object): # <<<<<<<<<<<<<< + * cdef object name + * def __init__(self, name): + */ +struct __pyx_MemviewEnum_obj { + PyObject_HEAD + PyObject *name; +}; + + +/* "View.MemoryView":326 + * + * @cname('__pyx_memoryview') + * cdef class memoryview(object): # <<<<<<<<<<<<<< + * + * cdef object obj + */ +struct __pyx_memoryview_obj { + PyObject_HEAD + struct __pyx_vtabstruct_memoryview *__pyx_vtab; + PyObject *obj; + PyObject *_size; + PyObject *_array_interface; + PyThread_type_lock lock; + __pyx_atomic_int acquisition_count[2]; + __pyx_atomic_int *acquisition_count_aligned_p; + Py_buffer view; + int flags; + int dtype_is_object; + __Pyx_TypeInfo *typeinfo; +}; + + +/* "View.MemoryView":951 + * + * @cname('__pyx_memoryviewslice') + * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< + * "Internal class for passing memoryview slices to Python" + * + */ +struct __pyx_memoryviewslice_obj { + struct __pyx_memoryview_obj __pyx_base; + __Pyx_memviewslice from_slice; + PyObject *from_object; + PyObject *(*to_object_func)(char *); + int (*to_dtype_func)(char *, PyObject *); +}; + + + +/* "View.MemoryView":103 + * + * @cname("__pyx_array") + * cdef class array: # <<<<<<<<<<<<<< + * + * cdef: + */ + +struct __pyx_vtabstruct_array { + PyObject *(*get_memview)(struct __pyx_array_obj *); +}; +static struct __pyx_vtabstruct_array *__pyx_vtabptr_array; + + +/* "View.MemoryView":326 + * + * @cname('__pyx_memoryview') + * cdef class memoryview(object): # <<<<<<<<<<<<<< + * + * cdef object obj + */ + +struct __pyx_vtabstruct_memoryview { + char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); + PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); + PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *); + PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *); +}; +static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview; + + +/* "View.MemoryView":951 + * + * @cname('__pyx_memoryviewslice') + * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< + * "Internal class for passing memoryview slices to Python" + * + */ + +struct __pyx_vtabstruct__memoryviewslice { + struct __pyx_vtabstruct_memoryview __pyx_base; +}; +static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_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 + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* BufferFormatCheck.proto */ +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type); // PROTO + +/* MemviewSliceInit.proto */ +#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d +#define __Pyx_MEMVIEW_DIRECT 1 +#define __Pyx_MEMVIEW_PTR 2 +#define __Pyx_MEMVIEW_FULL 4 +#define __Pyx_MEMVIEW_CONTIG 8 +#define __Pyx_MEMVIEW_STRIDED 16 +#define __Pyx_MEMVIEW_FOLLOW 32 +#define __Pyx_IS_C_CONTIG 1 +#define __Pyx_IS_F_CONTIG 2 +static int __Pyx_init_memviewslice( + struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference); +static CYTHON_INLINE int __pyx_add_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); +static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); +#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p) +#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview)) +#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__) +#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__) +static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* PyThreadStateGet.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* IncludeStringH.proto */ +#include + +/* BytesEquals.proto */ +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); + +/* UnicodeEquals.proto */ +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); + +/* StrEquals.proto */ +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals +#else +#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals +#endif + +/* UnaryNegOverflows.proto */ +#define UNARY_NEG_WOULD_OVERFLOW(x)\ + (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) + +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/ +/* GetAttr.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); + +/* decode_c_string.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/* SaveResetException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* SwapException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +/* ListCompAppend.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +/* PyIntBinop.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + +/* ListExtend.proto */ +static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject* none = _PyList_Extend((PyListObject*)L, v); + if (unlikely(!none)) + return -1; + Py_DECREF(none); + return 0; +#else + return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v); +#endif +} + +/* ListAppend.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* None.proto */ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +/* BufferStructDeclare.proto */ +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +/* None.proto */ +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +/* MemviewSliceIsContig.proto */ +static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, + char order, int ndim); + +/* OverlappingSlices.proto */ +static int __pyx_slices_overlap(__Pyx_memviewslice *slice1, + __Pyx_memviewslice *slice2, + int ndim, size_t itemsize); + +/* Capsule.proto */ +static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig); + +/* MemviewDtypeToObject.proto */ +static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp); +static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* None.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(__cplusplus) && CYTHON_CCOMPLEX && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +/* None.proto */ +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +/* None.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +/* None.proto */ +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +/* None.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); + +/* MemviewSliceCopyTemplate.proto */ +static __Pyx_memviewslice +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* TypeInfoCompare.proto */ +static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b); + +/* MemviewSliceValidateAndInit.proto */ +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj); + +/* ObjectToMemviewSlice.proto */ +static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *); + +/* ObjectToMemviewSlice.proto */ +static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* PyIdentifierFromString.proto */ +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +/* ModuleImport.proto */ +static PyObject *__Pyx_ImportModule(const char *name); + +/* TypeImport.proto */ +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/ +static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/ +static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/ +static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/ +static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ +static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ +static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'cpython' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'Orange.distance._distance' */ +static PyTypeObject *__pyx_array_type = 0; +static PyTypeObject *__pyx_MemviewEnum_type = 0; +static PyTypeObject *__pyx_memoryview_type = 0; +static PyTypeObject *__pyx_memoryviewslice_type = 0; +static PyObject *generic = 0; +static PyObject *strided = 0; +static PyObject *indirect = 0; +static PyObject *contiguous = 0; +static PyObject *indirect_contiguous = 0; +static int __pyx_memoryview_thread_locks_used; +static PyThread_type_lock __pyx_memoryview_thread_locks[8]; +static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice); /*proto*/ +static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ +static void *__pyx_align_pointer(void *, size_t); /*proto*/ +static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ +static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/ +static PyObject *_unellipsify(PyObject *, int); /*proto*/ +static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/ +static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/ +static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/ +static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/ +static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/ +static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/ +static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/ +static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/ +static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/ +static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/ +static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/ +static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/ +static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/ +static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/ +static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/ +static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/ +static int __pyx_memoryview_err(PyObject *, char *); /*proto*/ +static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/ +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/ +static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/ +static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ +static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ +static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/ +static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/ +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "Orange.distance._distance" +int __pyx_module_is_main_Orange__distance___distance = 0; + +/* Implementation of 'Orange.distance._distance' */ +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_MemoryError; +static PyObject *__pyx_builtin_enumerate; +static PyObject *__pyx_builtin_Ellipsis; +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_id; +static PyObject *__pyx_builtin_IndexError; +static const char __pyx_k_O[] = "O"; +static const char __pyx_k_c[] = "c"; +static const char __pyx_k_d[] = "d"; +static const char __pyx_k_x[] = "x"; +static const char __pyx_k_id[] = "id"; +static const char __pyx_k_np[] = "np"; +static const char __pyx_k_ps[] = "ps"; +static const char __pyx_k_x1[] = "x1"; +static const char __pyx_k_x2[] = "x2"; +static const char __pyx_k__29[] = "_"; +static const char __pyx_k_all[] = "all"; +static const char __pyx_k_col[] = "col"; +static const char __pyx_k_obj[] = "obj"; +static const char __pyx_k_row[] = "row"; +static const char __pyx_k_val[] = "val"; +static const char __pyx_k_base[] = "base"; +static const char __pyx_k_col1[] = "col1"; +static const char __pyx_k_col2[] = "col2"; +static const char __pyx_k_mads[] = "mads"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_mode[] = "mode"; +static const char __pyx_k_name[] = "name"; +static const char __pyx_k_ndim[] = "ndim"; +static const char __pyx_k_ones[] = "ones"; +static const char __pyx_k_pack[] = "pack"; +static const char __pyx_k_row1[] = "row1"; +static const char __pyx_k_row2[] = "row2"; +static const char __pyx_k_same[] = "same"; +static const char __pyx_k_size[] = "size"; +static const char __pyx_k_sqrt[] = "sqrt"; +static const char __pyx_k_step[] = "step"; +static const char __pyx_k_stop[] = "stop"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_val1[] = "val1"; +static const char __pyx_k_val2[] = "val2"; +static const char __pyx_k_vars[] = "vars"; +static const char __pyx_k_ASCII[] = "ASCII"; +static const char __pyx_k_class[] = "__class__"; +static const char __pyx_k_dtype[] = "dtype"; +static const char __pyx_k_empty[] = "empty"; +static const char __pyx_k_error[] = "error"; +static const char __pyx_k_flags[] = "flags"; +static const char __pyx_k_isnan[] = "isnan"; +static const char __pyx_k_ival1[] = "ival1"; +static const char __pyx_k_ival2[] = "ival2"; +static const char __pyx_k_means[] = "means"; +static const char __pyx_k_numpy[] = "numpy"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_shape[] = "shape"; +static const char __pyx_k_start[] = "start"; +static const char __pyx_k_union[] = "union"; +static const char __pyx_k_zeros[] = "zeros"; +static const char __pyx_k_double[] = "double"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_format[] = "format"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_in_one[] = "in_one"; +static const char __pyx_k_n_cols[] = "n_cols"; +static const char __pyx_k_n_rows[] = "n_rows"; +static const char __pyx_k_name_2[] = "__name__"; +static const char __pyx_k_struct[] = "struct"; +static const char __pyx_k_unpack[] = "unpack"; +static const char __pyx_k_fortran[] = "fortran"; +static const char __pyx_k_in_both[] = "in_both"; +static const char __pyx_k_medians[] = "medians"; +static const char __pyx_k_memview[] = "memview"; +static const char __pyx_k_n_rows1[] = "n_rows1"; +static const char __pyx_k_n_rows2[] = "n_rows2"; +static const char __pyx_k_nonnans[] = "nonnans"; +static const char __pyx_k_Ellipsis[] = "Ellipsis"; +static const char __pyx_k_in1_unk2[] = "in1_unk2"; +static const char __pyx_k_itemsize[] = "itemsize"; +static const char __pyx_k_nonzeros[] = "nonzeros"; +static const char __pyx_k_unk1_in2[] = "unk1_in2"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_distances[] = "distances"; +static const char __pyx_k_enumerate[] = "enumerate"; +static const char __pyx_k_normalize[] = "normalize"; +static const char __pyx_k_not1_unk2[] = "not1_unk2"; +static const char __pyx_k_unk1_not2[] = "unk1_not2"; +static const char __pyx_k_unk1_unk2[] = "unk1_unk2"; +static const char __pyx_k_IndexError[] = "IndexError"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_fit_params[] = "fit_params"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_fit_jaccard[] = "fit_jaccard"; +static const char __pyx_k_RuntimeError[] = "RuntimeError"; +static const char __pyx_k_dist_missing[] = "dist_missing"; +static const char __pyx_k_intersection[] = "intersection"; +static const char __pyx_k_jaccard_cols[] = "jaccard_cols"; +static const char __pyx_k_jaccard_rows[] = "jaccard_rows"; +static const char __pyx_k_dist_missing2[] = "dist_missing2"; +static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; +static const char __pyx_k_euclidean_cols[] = "euclidean_cols"; +static const char __pyx_k_euclidean_rows[] = "euclidean_rows"; +static const char __pyx_k_manhattan_cols[] = "manhattan_cols"; +static const char __pyx_k_manhattan_rows[] = "manhattan_rows"; +static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; +static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; +static const char __pyx_k_strided_and_direct[] = ""; +static const char __pyx_k_strided_and_indirect[] = ""; +static const char __pyx_k_contiguous_and_direct[] = ""; +static const char __pyx_k_MemoryView_of_r_object[] = ""; +static const char __pyx_k_MemoryView_of_r_at_0x_x[] = ""; +static const char __pyx_k_contiguous_and_indirect[] = ""; +static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'"; +static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d."; +static const char __pyx_k_Orange_distance__distance[] = "Orange.distance._distance"; +static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; +static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; +static const char __pyx_k_strided_and_direct_or_indirect[] = ""; +static const char __pyx_k_Users_janez_Dropbox_orange3_Ora[] = "/Users/janez/Dropbox/orange3/Orange/distance/_distance.pyx"; +static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; +static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; +static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory."; +static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array"; +static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported"; +static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s"; +static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; +static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)"; +static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object"; +static const char __pyx_k_cannot_normalize_the_data_has_no[] = "cannot normalize: the data has no variance"; +static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)"; +static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides."; +static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; +static PyObject *__pyx_n_s_ASCII; +static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri; +static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is; +static PyObject *__pyx_kp_s_Cannot_index_with_type_s; +static PyObject *__pyx_n_s_Ellipsis; +static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_IndexError; +static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte; +static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr; +static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d; +static PyObject *__pyx_n_s_MemoryError; +static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x; +static PyObject *__pyx_kp_s_MemoryView_of_r_object; +static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; +static PyObject *__pyx_n_b_O; +static PyObject *__pyx_n_s_Orange_distance__distance; +static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; +static PyObject *__pyx_kp_s_Users_janez_Dropbox_orange3_Ora; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s__29; +static PyObject *__pyx_n_s_all; +static PyObject *__pyx_n_s_allocate_buffer; +static PyObject *__pyx_n_s_base; +static PyObject *__pyx_n_s_c; +static PyObject *__pyx_n_u_c; +static PyObject *__pyx_kp_s_cannot_normalize_the_data_has_no; +static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_col; +static PyObject *__pyx_n_s_col1; +static PyObject *__pyx_n_s_col2; +static PyObject *__pyx_kp_s_contiguous_and_direct; +static PyObject *__pyx_kp_s_contiguous_and_indirect; +static PyObject *__pyx_n_s_d; +static PyObject *__pyx_n_s_dist_missing; +static PyObject *__pyx_n_s_dist_missing2; +static PyObject *__pyx_n_s_distances; +static PyObject *__pyx_n_s_double; +static PyObject *__pyx_n_s_dtype; +static PyObject *__pyx_n_s_dtype_is_object; +static PyObject *__pyx_n_s_empty; +static PyObject *__pyx_n_s_encode; +static PyObject *__pyx_n_s_enumerate; +static PyObject *__pyx_n_s_error; +static PyObject *__pyx_n_s_euclidean_cols; +static PyObject *__pyx_n_s_euclidean_rows; +static PyObject *__pyx_n_s_fit_jaccard; +static PyObject *__pyx_n_s_fit_params; +static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_format; +static PyObject *__pyx_n_s_fortran; +static PyObject *__pyx_n_u_fortran; +static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; +static PyObject *__pyx_n_s_id; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_in1_unk2; +static PyObject *__pyx_n_s_in_both; +static PyObject *__pyx_n_s_in_one; +static PyObject *__pyx_n_s_intersection; +static PyObject *__pyx_n_s_isnan; +static PyObject *__pyx_n_s_itemsize; +static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; +static PyObject *__pyx_n_s_ival1; +static PyObject *__pyx_n_s_ival2; +static PyObject *__pyx_n_s_jaccard_cols; +static PyObject *__pyx_n_s_jaccard_rows; +static PyObject *__pyx_n_s_mads; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_manhattan_cols; +static PyObject *__pyx_n_s_manhattan_rows; +static PyObject *__pyx_n_s_means; +static PyObject *__pyx_n_s_medians; +static PyObject *__pyx_n_s_memview; +static PyObject *__pyx_n_s_mode; +static PyObject *__pyx_n_s_n_cols; +static PyObject *__pyx_n_s_n_rows; +static PyObject *__pyx_n_s_n_rows1; +static PyObject *__pyx_n_s_n_rows2; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_name_2; +static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; +static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_ndim; +static PyObject *__pyx_n_s_nonnans; +static PyObject *__pyx_n_s_nonzeros; +static PyObject *__pyx_n_s_normalize; +static PyObject *__pyx_n_s_not1_unk2; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_n_s_obj; +static PyObject *__pyx_n_s_ones; +static PyObject *__pyx_n_s_pack; +static PyObject *__pyx_n_s_ps; +static PyObject *__pyx_n_s_pyx_getbuffer; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_row; +static PyObject *__pyx_n_s_row1; +static PyObject *__pyx_n_s_row2; +static PyObject *__pyx_n_s_same; +static PyObject *__pyx_n_s_shape; +static PyObject *__pyx_n_s_size; +static PyObject *__pyx_n_s_sqrt; +static PyObject *__pyx_n_s_start; +static PyObject *__pyx_n_s_step; +static PyObject *__pyx_n_s_stop; +static PyObject *__pyx_kp_s_strided_and_direct; +static PyObject *__pyx_kp_s_strided_and_direct_or_indirect; +static PyObject *__pyx_kp_s_strided_and_indirect; +static PyObject *__pyx_n_s_struct; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_kp_s_unable_to_allocate_array_data; +static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str; +static PyObject *__pyx_n_s_union; +static PyObject *__pyx_n_s_unk1_in2; +static PyObject *__pyx_n_s_unk1_not2; +static PyObject *__pyx_n_s_unk1_unk2; +static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; +static PyObject *__pyx_n_s_unpack; +static PyObject *__pyx_n_s_val; +static PyObject *__pyx_n_s_val1; +static PyObject *__pyx_n_s_val2; +static PyObject *__pyx_n_s_vars; +static PyObject *__pyx_n_s_x; +static PyObject *__pyx_n_s_x1; +static PyObject *__pyx_n_s_x2; +static PyObject *__pyx_n_s_zeros; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, CYTHON_UNUSED PyObject *__pyx_v__); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ +static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ +static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ +static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_neg_1; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__17; +static PyObject *__pyx_slice__18; +static PyObject *__pyx_slice__19; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__21; +static PyObject *__pyx_tuple__23; +static PyObject *__pyx_tuple__25; +static PyObject *__pyx_tuple__27; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__32; +static PyObject *__pyx_tuple__34; +static PyObject *__pyx_tuple__36; +static PyObject *__pyx_tuple__37; +static PyObject *__pyx_tuple__38; +static PyObject *__pyx_tuple__39; +static PyObject *__pyx_tuple__40; +static PyObject *__pyx_codeobj__22; +static PyObject *__pyx_codeobj__24; +static PyObject *__pyx_codeobj__26; +static PyObject *__pyx_codeobj__28; +static PyObject *__pyx_codeobj__31; +static PyObject *__pyx_codeobj__33; +static PyObject *__pyx_codeobj__35; + +/* "Orange/distance/_distance.pyx":19 + * + * # This function is unused, but kept here for any future use + * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< + * cdef int col + * for col in range(dividers.shape[0]): + */ + +static PyObject *__pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_dividers) { + int __pyx_v_col; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + __Pyx_RefNannySetupContext("_check_division_by_zero", 0); + + /* "Orange/distance/_distance.pyx":21 + * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): + * cdef int col + * for col in range(dividers.shape[0]): # <<<<<<<<<<<<<< + * if dividers[col] == 0 and not x[:, col].isnan().all(): + * raise ValueError("cannot normalize: the data has no variance") + */ + __pyx_t_1 = (__pyx_v_dividers.shape[0]); + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_col = __pyx_t_2; + + /* "Orange/distance/_distance.pyx":22 + * cdef int col + * for col in range(dividers.shape[0]): + * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< + * raise ValueError("cannot normalize: the data has no variance") + * + */ + __pyx_t_4 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_dividers.data + __pyx_t_4 * __pyx_v_dividers.strides[0]) ))) == 0.0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_3 = __pyx_t_5; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_8.data = __pyx_v_x.data; + __pyx_t_8.memview = __pyx_v_x.memview; + __PYX_INC_MEMVIEW(&__pyx_t_8, 0); + __pyx_t_8.shape[0] = __pyx_v_x.shape[0]; +__pyx_t_8.strides[0] = __pyx_v_x.strides[0]; + __pyx_t_8.suboffsets[0] = -1; + +{ + Py_ssize_t __pyx_tmp_idx = __pyx_v_col; + Py_ssize_t __pyx_tmp_shape = __pyx_v_x.shape[1]; + Py_ssize_t __pyx_tmp_stride = __pyx_v_x.strides[1]; + if (0 && (__pyx_tmp_idx < 0)) + __pyx_tmp_idx += __pyx_tmp_shape; + if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) { + PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)"); + __PYX_ERR(0, 22, __pyx_L1_error) + } + __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride; +} + +__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (__pyx_t_9) { + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (__pyx_t_7) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else { + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_11 = ((!__pyx_t_5) != 0); + __pyx_t_3 = __pyx_t_11; + __pyx_L6_bool_binop_done:; + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":23 + * for col in range(dividers.shape[0]): + * if dividers[col] == 0 and not x[:, col].isnan().all(): + * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(0, 23, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":22 + * cdef int col + * for col in range(dividers.shape[0]): + * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< + * raise ValueError("cannot normalize: the data has no variance") + * + */ + } + } + + /* "Orange/distance/_distance.pyx":19 + * + * # This function is unused, but kept here for any future use + * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< + * cdef int col + * for col in range(dividers.shape[0]): + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("Orange.distance._distance._check_division_by_zero", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":26 + * + * + * cdef _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cdef int row1, row2 + * for row1 in range(distances.shape[0]): + */ + +static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice __pyx_v_distances) { + int __pyx_v_row1; + int __pyx_v_row2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + Py_ssize_t __pyx_t_5; + Py_ssize_t __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + __Pyx_RefNannySetupContext("_lower_to_symmetric", 0); + + /* "Orange/distance/_distance.pyx":28 + * cdef _lower_to_symmetric(double [:, :] distances): + * cdef int row1, row2 + * for row1 in range(distances.shape[0]): # <<<<<<<<<<<<<< + * for row2 in range(row1): + * distances[row2, row1] = distances[row1, row2] + */ + __pyx_t_1 = (__pyx_v_distances.shape[0]); + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_row1 = __pyx_t_2; + + /* "Orange/distance/_distance.pyx":29 + * cdef int row1, row2 + * for row1 in range(distances.shape[0]): + * for row2 in range(row1): # <<<<<<<<<<<<<< + * distances[row2, row1] = distances[row1, row2] + * + */ + __pyx_t_3 = __pyx_v_row1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row2 = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":30 + * for row1 in range(distances.shape[0]): + * for row2 in range(row1): + * distances[row2, row1] = distances[row1, row2] # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __pyx_v_row1; + __pyx_t_6 = __pyx_v_row2; + __pyx_t_7 = __pyx_v_row2; + __pyx_t_8 = __pyx_v_row1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_7 * __pyx_v_distances.strides[0]) ) + __pyx_t_8 * __pyx_v_distances.strides[1]) )) = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_5 * __pyx_v_distances.strides[0]) ) + __pyx_t_6 * __pyx_v_distances.strides[1]) ))); + } + } + + /* "Orange/distance/_distance.pyx":26 + * + * + * cdef _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cdef int row1, row2 + * for row1 in range(distances.shape[0]): + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":33 + * + * + * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows[] = "euclidean_rows(ndarray x1, ndarray x2, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows = {"euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_euclidean_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("euclidean_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; + PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, 1); __PYX_ERR(0, 33, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, 2); __PYX_ERR(0, 33, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 33, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_fit_params = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 33, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 34, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + int __pyx_v_ival1; + int __pyx_v_ival2; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_same; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_4; + int __pyx_t_5; + npy_intp __pyx_t_6; + npy_intp __pyx_t_7; + Py_ssize_t __pyx_t_8; + Py_ssize_t __pyx_t_9; + Py_ssize_t __pyx_t_10; + Py_ssize_t __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + __pyx_t_5numpy_float64_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + __pyx_t_5numpy_float64_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + Py_ssize_t __pyx_t_42; + Py_ssize_t __pyx_t_43; + Py_ssize_t __pyx_t_44; + Py_ssize_t __pyx_t_45; + PyObject *__pyx_t_46 = NULL; + __Pyx_RefNannySetupContext("euclidean_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":37 + * fit_params): + * cdef: + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * double [:] means = fit_params["means"] + * double [:, :] dist_missing = fit_params["dist_missing"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":38 + * cdef: + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 38, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":39 + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] + * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; + + /* "Orange/distance/_distance.pyx":40 + * double [:] means = fit_params["means"] + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":41 + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":47 + * int ival1, ival2 + * double [:, :] distances + * char same = x1 is x2 # <<<<<<<<<<<<<< + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + */ + __pyx_t_5 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); + __pyx_v_same = __pyx_t_5; + + /* "Orange/distance/_distance.pyx":49 + * char same = x1 is x2 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + */ + __pyx_t_6 = (__pyx_v_x1->dimensions[0]); + __pyx_t_7 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_6; + __pyx_v_n_cols = __pyx_t_7; + + /* "Orange/distance/_distance.pyx":50 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing) == len(dist_missing2) + */ + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); + + /* "Orange/distance/_distance.pyx":51 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_8 == __pyx_t_9); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":52 + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + */ + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_9 == __pyx_t_10); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_10 == __pyx_t_11); + } + } + } + } + + /* "Orange/distance/_distance.pyx":51 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + */ + if (unlikely(!(__pyx_t_5 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 51, __pyx_L1_error) + } + } + #endif + + /* "Orange/distance/_distance.pyx":53 + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing) == len(dist_missing2) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * + * with nogil: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); + __pyx_t_14 = 0; + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; + + /* "Orange/distance/_distance.pyx":55 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":56 + * + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(row1 if same else n_rows2): + * d = 0 + */ + __pyx_t_15 = __pyx_v_n_rows1; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_row1 = __pyx_t_16; + + /* "Orange/distance/_distance.pyx":57 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_same != 0)) { + __pyx_t_17 = __pyx_v_row1; + } else { + __pyx_t_17 = __pyx_v_n_rows2; + } + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { + __pyx_v_row2 = __pyx_t_18; + + /* "Orange/distance/_distance.pyx":58 + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":59 + * for row2 in range(row1 if same else n_rows2): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: + * continue + */ + __pyx_t_19 = __pyx_v_n_cols; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col = __pyx_t_20; + + /* "Orange/distance/_distance.pyx":60 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + */ + __pyx_t_21 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":61 + * for col in range(n_cols): + * if vars[col] == -2: + * continue # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + */ + goto __pyx_L10_continue; + + /* "Orange/distance/_distance.pyx":60 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + */ + } + + /* "Orange/distance/_distance.pyx":62 + * if vars[col] == -2: + * continue + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + */ + __pyx_t_22 = __pyx_v_row1; + __pyx_t_23 = __pyx_v_col; + __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_25 = __pyx_v_row2; + __pyx_t_26 = __pyx_v_col; + __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_24; + __pyx_v_val2 = __pyx_t_27; + + /* "Orange/distance/_distance.pyx":63 + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: + */ + __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L14_bool_binop_done:; + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":64 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif vars[col] == -1: + * ival1, ival2 = int(val1), int(val2) + */ + __pyx_t_29 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":63 + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":65 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + */ + __pyx_t_30 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_30 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":66 + * d += dist_missing2[col] + * elif vars[col] == -1: + * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + */ + __pyx_v_ival1 = ((int)__pyx_v_val1); + __pyx_v_ival2 = ((int)__pyx_v_val2); + + /* "Orange/distance/_distance.pyx":67 + * elif vars[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":68 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + */ + __pyx_t_31 = __pyx_v_col; + __pyx_t_32 = __pyx_v_ival2; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); + + /* "Orange/distance/_distance.pyx":67 + * elif vars[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":69 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":70 + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< + * elif ival1 != ival2: + * d += 1 + */ + __pyx_t_33 = __pyx_v_col; + __pyx_t_34 = __pyx_v_ival1; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); + + /* "Orange/distance/_distance.pyx":69 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":71 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: + */ + __pyx_t_5 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":72 + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + * d += 1 # <<<<<<<<<<<<<< + * elif normalize: + * if npy_isnan(val1): + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":71 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: + */ + } + __pyx_L16:; + + /* "Orange/distance/_distance.pyx":65 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":73 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + */ + __pyx_t_5 = (__pyx_v_normalize != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":74 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * elif npy_isnan(val2): + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":75 + * elif normalize: + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + */ + __pyx_t_35 = __pyx_v_col; + __pyx_t_36 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_35 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_36 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":74 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * elif npy_isnan(val2): + */ + goto __pyx_L17; + } + + /* "Orange/distance/_distance.pyx":76 + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * else: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":77 + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * elif npy_isnan(val2): + * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += ((val1 - val2) ** 2 / vars[col]) / 2 + */ + __pyx_t_37 = __pyx_v_col; + __pyx_t_38 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_37 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_38 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":76 + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * else: + */ + goto __pyx_L17; + } + + /* "Orange/distance/_distance.pyx":79 + * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + * else: + * d += ((val1 - val2) ** 2 / vars[col]) / 2 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + /*else*/ { + __pyx_t_39 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + ((pow((__pyx_v_val1 - __pyx_v_val2), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_39 * __pyx_v_vars.strides[0]) )))) / 2.0)); + } + __pyx_L17:; + + /* "Orange/distance/_distance.pyx":73 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":81 + * d += ((val1 - val2) ** 2 / vars[col]) / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += (val2 - means[col]) ** 2 + vars[col] + * elif npy_isnan(val2): + */ + /*else*/ { + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":82 + * else: + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += (val1 - means[col]) ** 2 + vars[col] + */ + __pyx_t_40 = __pyx_v_col; + __pyx_t_41 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_40 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_41 * __pyx_v_vars.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":81 + * d += ((val1 - val2) ** 2 / vars[col]) / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += (val2 - means[col]) ** 2 + vars[col] + * elif npy_isnan(val2): + */ + goto __pyx_L18; + } + + /* "Orange/distance/_distance.pyx":83 + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 + vars[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col]) ** 2 + vars[col] + * else: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":84 + * d += (val2 - means[col]) ** 2 + vars[col] + * elif npy_isnan(val2): + * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< + * else: + * d += (val1 - val2) ** 2 + */ + __pyx_t_42 = __pyx_v_col; + __pyx_t_43 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_42 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_43 * __pyx_v_vars.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":83 + * if npy_isnan(val1): + * d += (val2 - means[col]) ** 2 + vars[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col]) ** 2 + vars[col] + * else: + */ + goto __pyx_L18; + } + + /* "Orange/distance/_distance.pyx":86 + * d += (val1 - means[col]) ** 2 + vars[col] + * else: + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * if same: + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); + } + __pyx_L18:; + } + __pyx_L13:; + __pyx_L10_continue:; + } + + /* "Orange/distance/_distance.pyx":87 + * else: + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if same: + * _lower_to_symmetric(distances) + */ + __pyx_t_44 = __pyx_v_row1; + __pyx_t_45 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } + } + } + + /* "Orange/distance/_distance.pyx":55 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":88 + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return np.sqrt(distances) + */ + __pyx_t_5 = (__pyx_v_same != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":89 + * distances[row1, row2] = d + * if same: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return np.sqrt(distances) + * + */ + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":88 + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return np.sqrt(distances) + */ + } + + /* "Orange/distance/_distance.pyx":90 + * if same: + * _lower_to_symmetric(distances) + * return np.sqrt(distances) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_12 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_13, function); + } + } + if (!__pyx_t_12) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_46); + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_46, 0, __pyx_t_12); __pyx_t_12 = NULL; + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_46, 0+1, __pyx_t_14); + __pyx_t_14 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0; + } + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":33 + * + * + * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_46); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":93 + * + * + * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] means = fit_params["means"] + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_2euclidean_cols[] = "euclidean_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols = {"euclidean_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_2euclidean_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("euclidean_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 93, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 93, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 93, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_3; + npy_intp __pyx_t_4; + npy_intp __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + PyObject *__pyx_t_39 = NULL; + __Pyx_RefNannySetupContext("euclidean_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 93, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":95 + * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< + * double [:] vars = fit_params["vars"] + * char normalize = fit_params["normalize"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 95, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":96 + * cdef: + * double [:] means = fit_params["means"] + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":97 + * double [:] means = fit_params["means"] + * double [:] vars = fit_params["vars"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * + * int n_rows, n_cols, col1, col2, row + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_3; + + /* "Orange/distance/_distance.pyx":103 + * double [:, :] distances + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: + */ + __pyx_t_4 = (__pyx_v_x->dimensions[0]); + __pyx_t_5 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_4; + __pyx_v_n_cols = __pyx_t_5; + + /* "Orange/distance/_distance.pyx":104 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * with nogil: + * for col1 in range(n_cols): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; + + /* "Orange/distance/_distance.pyx":105 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":106 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * d = 0 + */ + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col1 = __pyx_t_11; + + /* "Orange/distance/_distance.pyx":107 + * with nogil: + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): + */ + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; + + /* "Orange/distance/_distance.pyx":108 + * for col1 in range(n_cols): + * for col2 in range(col1): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":109 + * for col2 in range(col1): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + */ + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":110 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if normalize: + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + */ + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col1; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; + + /* "Orange/distance/_distance.pyx":111 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + */ + __pyx_t_22 = (__pyx_v_normalize != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":112 + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) # <<<<<<<<<<<<<< + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + * if npy_isnan(val1): + */ + __pyx_t_23 = __pyx_v_col1; + __pyx_t_24 = __pyx_v_col1; + __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_23 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_24 * __pyx_v_vars.strides[0]) )))))); + + /* "Orange/distance/_distance.pyx":113 + * if normalize: + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_25 = __pyx_v_col2; + __pyx_t_26 = __pyx_v_col2; + __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_25 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_26 * __pyx_v_vars.strides[0]) )))))); + + /* "Orange/distance/_distance.pyx":114 + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":115 + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":116 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += val2 ** 2 + 0.5 + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":115 + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":118 + * d += 1 + * else: + * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 ** 2 + 0.5 + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val2, 2.0) + 0.5)); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":114 + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":119 + * else: + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 ** 2 + 0.5 + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":120 + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): + * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += (val1 - val2) ** 2 + */ + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":119 + * else: + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 ** 2 + 0.5 + * else: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":122 + * d += val1 ** 2 + 0.5 + * else: + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); + } + __pyx_L13:; + + /* "Orange/distance/_distance.pyx":111 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":124 + * d += (val1 - val2) ** 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ + */ + /*else*/ { + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":125 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":126 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< + * + (means[col1] - means[col2]) ** 2 + * else: + */ + __pyx_t_27 = __pyx_v_col1; + __pyx_t_28 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":127 + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< + * else: + * d += (val2 - means[col1]) ** 2 + vars[col1] + */ + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":126 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< + * + (means[col1] - means[col2]) ** 2 + * else: + */ + __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_27 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_28 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_29 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))), 2.0))); + + /* "Orange/distance/_distance.pyx":125 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":129 + * + (means[col1] - means[col2]) ** 2 + * else: + * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += (val1 - means[col2]) ** 2 + vars[col2] + */ + /*else*/ { + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_32 * __pyx_v_vars.strides[0]) ))))); + } + __pyx_L16:; + + /* "Orange/distance/_distance.pyx":124 + * d += (val1 - val2) ** 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":130 + * else: + * d += (val2 - means[col1]) ** 2 + vars[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col2]) ** 2 + vars[col2] + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":131 + * d += (val2 - means[col1]) ** 2 + vars[col1] + * elif npy_isnan(val2): + * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< + * else: + * d += (val1 - val2) ** 2 + */ + __pyx_t_33 = __pyx_v_col2; + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_34 * __pyx_v_vars.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":130 + * else: + * d += (val2 - means[col1]) ** 2 + vars[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += (val1 - means[col2]) ** 2 + vars[col2] + * else: + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":133 + * d += (val1 - means[col2]) ** 2 + vars[col2] + * else: + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return np.sqrt(distances) + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); + } + __pyx_L15:; + } + __pyx_L12:; + } + + /* "Orange/distance/_distance.pyx":134 + * else: + * d += (val1 - val2) ** 2 + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return np.sqrt(distances) + * + */ + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + __pyx_t_37 = __pyx_v_col2; + __pyx_t_38 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } + } + } + + /* "Orange/distance/_distance.pyx":105 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":135 + * d += (val1 - val2) ** 2 + * distances[col1, col2] = distances[col2, col1] = d + * return np.sqrt(distances) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_6) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_39); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_39, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_39, 0+1, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":93 + * + * + * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] means = fit_params["means"] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __Pyx_XDECREF(__pyx_t_39); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":138 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows = {"manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("manhattan_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; + PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, 1); __PYX_ERR(0, 138, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, 2); __PYX_ERR(0, 138, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 138, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_fit_params = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 138, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; + char __pyx_v_same; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + int __pyx_v_ival1; + int __pyx_v_ival2; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_4; + int __pyx_t_5; + npy_intp __pyx_t_6; + npy_intp __pyx_t_7; + Py_ssize_t __pyx_t_8; + Py_ssize_t __pyx_t_9; + Py_ssize_t __pyx_t_10; + Py_ssize_t __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + __pyx_t_5numpy_float64_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + __pyx_t_5numpy_float64_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + Py_ssize_t __pyx_t_42; + Py_ssize_t __pyx_t_43; + Py_ssize_t __pyx_t_44; + Py_ssize_t __pyx_t_45; + __Pyx_RefNannySetupContext("manhattan_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":142 + * fit_params): + * cdef: + * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_medians = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":143 + * cdef: + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_mads = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":144 + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; + + /* "Orange/distance/_distance.pyx":145 + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * char same = x1 is x2 + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":146 + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * char same = x1 is x2 + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":147 + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] + * char same = x1 is x2 # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col + */ + __pyx_t_5 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); + __pyx_v_same = __pyx_t_5; + + /* "Orange/distance/_distance.pyx":154 + * double [:, :] distances + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + */ + __pyx_t_6 = (__pyx_v_x1->dimensions[0]); + __pyx_t_7 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_6; + __pyx_v_n_cols = __pyx_t_7; + + /* "Orange/distance/_distance.pyx":155 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * == len(dist_missing) == len(dist_missing2) + */ + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); + + /* "Orange/distance/_distance.pyx":156 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_8 == __pyx_t_9); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":157 + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + */ + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_9 == __pyx_t_10); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_10 == __pyx_t_11); + } + } + } + } + + /* "Orange/distance/_distance.pyx":156 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * + */ + if (unlikely(!(__pyx_t_5 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 156, __pyx_L1_error) + } + } + #endif + + /* "Orange/distance/_distance.pyx":159 + * == len(dist_missing) == len(dist_missing2) + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); + __pyx_t_14 = 0; + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; + + /* "Orange/distance/_distance.pyx":160 + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(row1 if same else n_rows2): + * d = 0 + */ + __pyx_t_15 = __pyx_v_n_rows1; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_row1 = __pyx_t_16; + + /* "Orange/distance/_distance.pyx":161 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_same != 0)) { + __pyx_t_17 = __pyx_v_row1; + } else { + __pyx_t_17 = __pyx_v_n_rows2; + } + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { + __pyx_v_row2 = __pyx_t_18; + + /* "Orange/distance/_distance.pyx":162 + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if mads[col] == -2: + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":163 + * for row2 in range(row1 if same else n_rows2): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if mads[col] == -2: + * continue + */ + __pyx_t_19 = __pyx_v_n_cols; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col = __pyx_t_20; + + /* "Orange/distance/_distance.pyx":164 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue + * + */ + __pyx_t_21 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":165 + * for col in range(n_cols): + * if mads[col] == -2: + * continue # <<<<<<<<<<<<<< + * + * val1, val2 = x1[row1, col], x2[row2, col] + */ + goto __pyx_L7_continue; + + /* "Orange/distance/_distance.pyx":164 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue + * + */ + } + + /* "Orange/distance/_distance.pyx":167 + * continue + * + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + */ + __pyx_t_22 = __pyx_v_row1; + __pyx_t_23 = __pyx_v_col; + __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_25 = __pyx_v_row2; + __pyx_t_26 = __pyx_v_col; + __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_24; + __pyx_v_val2 = __pyx_t_27; + + /* "Orange/distance/_distance.pyx":168 + * + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: + */ + __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L11_bool_binop_done:; + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":169 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + */ + __pyx_t_29 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":168 + * + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":170 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + */ + __pyx_t_30 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":171 + * d += dist_missing2[col] + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + */ + __pyx_v_ival1 = ((int)__pyx_v_val1); + __pyx_v_ival2 = ((int)__pyx_v_val2); + + /* "Orange/distance/_distance.pyx":172 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":173 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + */ + __pyx_t_31 = __pyx_v_col; + __pyx_t_32 = __pyx_v_ival2; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); + + /* "Orange/distance/_distance.pyx":172 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":174 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":175 + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< + * elif ival1 != ival2: + * d += 1 + */ + __pyx_t_33 = __pyx_v_col; + __pyx_t_34 = __pyx_v_ival1; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); + + /* "Orange/distance/_distance.pyx":174 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":176 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: + */ + __pyx_t_5 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":177 + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + * d += 1 # <<<<<<<<<<<<<< + * elif normalize: + * if npy_isnan(val1): + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":176 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: + */ + } + __pyx_L13:; + + /* "Orange/distance/_distance.pyx":170 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":178 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + */ + __pyx_t_5 = (__pyx_v_normalize != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":179 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":180 + * elif normalize: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + */ + __pyx_t_35 = __pyx_v_col; + __pyx_t_36 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":179 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":181 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":182 + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) / mads[col] / 2 + */ + __pyx_t_37 = __pyx_v_col; + __pyx_t_38 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":181 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":184 + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + /*else*/ { + __pyx_t_39 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":178 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":186 + * d += fabs(val1 - val2) / mads[col] / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): + */ + /*else*/ { + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":187 + * else: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] + */ + __pyx_t_40 = __pyx_v_col; + __pyx_t_41 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":186 + * d += fabs(val1 - val2) / mads[col] / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":188 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":189 + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) + */ + __pyx_t_42 = __pyx_v_col; + __pyx_t_43 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":188 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":191 + * d += fabs(val1 - medians[col]) + mads[col] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * + * distances[row1, row2] = d + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L15:; + } + __pyx_L10:; + __pyx_L7_continue:; + } + + /* "Orange/distance/_distance.pyx":193 + * d += fabs(val1 - val2) + * + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * + * if same: + */ + __pyx_t_44 = __pyx_v_row1; + __pyx_t_45 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } + } + + /* "Orange/distance/_distance.pyx":195 + * distances[row1, row2] = d + * + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + __pyx_t_5 = (__pyx_v_same != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":196 + * + * if same: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":195 + * distances[row1, row2] = d + * + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + } + + /* "Orange/distance/_distance.pyx":197 + * if same: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":138 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":200 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_6manhattan_cols[] = "manhattan_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_6manhattan_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("manhattan_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 200, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 200, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_3; + npy_intp __pyx_t_4; + npy_intp __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + __Pyx_RefNannySetupContext("manhattan_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 200, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":202 + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< + * double [:] mads = fit_params["mads"] + * char normalize = fit_params["normalize"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_medians = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":203 + * cdef: + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_mads = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":204 + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * + * int n_rows, n_cols, col1, col2, row + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_3; + + /* "Orange/distance/_distance.pyx":210 + * double [:, :] distances + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + */ + __pyx_t_4 = (__pyx_v_x->dimensions[0]); + __pyx_t_5 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_4; + __pyx_v_n_cols = __pyx_t_5; + + /* "Orange/distance/_distance.pyx":211 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; + + /* "Orange/distance/_distance.pyx":212 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * d = 0 + */ + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col1 = __pyx_t_11; + + /* "Orange/distance/_distance.pyx":213 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): + */ + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; + + /* "Orange/distance/_distance.pyx":214 + * for col1 in range(n_cols): + * for col2 in range(col1): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":215 + * for col2 in range(col1): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + */ + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":216 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + */ + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col1; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; + + /* "Orange/distance/_distance.pyx":217 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + */ + __pyx_t_22 = (__pyx_v_normalize != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":218 + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + */ + __pyx_t_23 = __pyx_v_col1; + __pyx_t_24 = __pyx_v_col1; + __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":219 + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_25 = __pyx_v_col2; + __pyx_t_26 = __pyx_v_col2; + __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":220 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":221 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":222 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += fabs(val2) + 0.5 + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":221 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":224 + * d += 1 + * else: + * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + } + __pyx_L11:; + + /* "Orange/distance/_distance.pyx":220 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":225 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":226 + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) + */ + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); + + /* "Orange/distance/_distance.pyx":225 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":228 + * d += fabs(val1) + 0.5 + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L10:; + + /* "Orange/distance/_distance.pyx":217 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + */ + goto __pyx_L9; + } + + /* "Orange/distance/_distance.pyx":230 + * d += fabs(val1 - val2) + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + */ + /*else*/ { + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":231 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":232 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + __pyx_t_27 = __pyx_v_col1; + __pyx_t_28 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":233 + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + */ + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":232 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); + + /* "Orange/distance/_distance.pyx":231 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":235 + * + fabs(medians[col1] - medians[col2]) + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] + */ + /*else*/ { + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); + } + __pyx_L13:; + + /* "Orange/distance/_distance.pyx":230 + * d += fabs(val1 - val2) + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":236 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":237 + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) + */ + __pyx_t_33 = __pyx_v_col2; + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":236 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":239 + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return distances + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L12:; + } + __pyx_L9:; + } + + /* "Orange/distance/_distance.pyx":240 + * else: + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + __pyx_t_37 = __pyx_v_col2; + __pyx_t_38 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } + } + + /* "Orange/distance/_distance.pyx":241 + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":200 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":244 + * + * + * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * cdef: + * int row, n_cols, nonzeros, nonnans + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_8fit_jaccard[] = "fit_jaccard(ndarray x, *_)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9fit_jaccard = {"fit_jaccard", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_8fit_jaccard}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + CYTHON_UNUSED PyObject *__pyx_v__ = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("fit_jaccard (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v__ = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v__)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v__); + } else { + __pyx_v__ = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "fit_jaccard") < 0)) __PYX_ERR(0, 244, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("fit_jaccard", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 244, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v__); __pyx_v__ = 0; + __Pyx_AddTraceback("Orange.distance._distance.fit_jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(__pyx_self, __pyx_v_x, __pyx_v__); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v__); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, CYTHON_UNUSED PyObject *__pyx_v__) { + int __pyx_v_row; + int __pyx_v_n_cols; + int __pyx_v_nonzeros; + int __pyx_v_nonnans; + double __pyx_v_val; + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_col; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_7; + int __pyx_t_8; + Py_ssize_t __pyx_t_9; + int __pyx_t_10; + Py_ssize_t __pyx_t_11; + Py_ssize_t __pyx_t_12; + int __pyx_t_13; + Py_ssize_t __pyx_t_14; + __Pyx_RefNannySetupContext("fit_jaccard", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 244, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":250 + * double [:] ps + * + * n_cols = x.shape[1] # <<<<<<<<<<<<<< + * ps = np.empty(n_cols, dtype=np.double) + * for col in range(n_cols): + */ + __pyx_v_n_cols = (__pyx_v_x->dimensions[1]); + + /* "Orange/distance/_distance.pyx":251 + * + * n_cols = x.shape[1] + * ps = np.empty(n_cols, dtype=np.double) # <<<<<<<<<<<<<< + * for col in range(n_cols): + * nonzeros = nonnans = 0 + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_double); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5); + if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_ps = __pyx_t_6; + __pyx_t_6.memview = NULL; + __pyx_t_6.data = NULL; + + /* "Orange/distance/_distance.pyx":252 + * n_cols = x.shape[1] + * ps = np.empty(n_cols, dtype=np.double) + * for col in range(n_cols): # <<<<<<<<<<<<<< + * nonzeros = nonnans = 0 + * for row in range(len(x)): + */ + __pyx_t_7 = __pyx_v_n_cols; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_col = __pyx_t_8; + + /* "Orange/distance/_distance.pyx":253 + * ps = np.empty(n_cols, dtype=np.double) + * for col in range(n_cols): + * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< + * for row in range(len(x)): + * val = x[row, col] + */ + __pyx_v_nonzeros = 0; + __pyx_v_nonnans = 0; + + /* "Orange/distance/_distance.pyx":254 + * for col in range(n_cols): + * nonzeros = nonnans = 0 + * for row in range(len(x)): # <<<<<<<<<<<<<< + * val = x[row, col] + * if not npy_isnan(val): + */ + __pyx_t_9 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 254, __pyx_L1_error) + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_row = __pyx_t_10; + + /* "Orange/distance/_distance.pyx":255 + * nonzeros = nonnans = 0 + * for row in range(len(x)): + * val = x[row, col] # <<<<<<<<<<<<<< + * if not npy_isnan(val): + * nonnans += 1 + */ + __pyx_t_11 = __pyx_v_row; + __pyx_t_12 = __pyx_v_col; + __pyx_v_val = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_x.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":256 + * for row in range(len(x)): + * val = x[row, col] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: + */ + __pyx_t_13 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); + if (__pyx_t_13) { + + /* "Orange/distance/_distance.pyx":257 + * val = x[row, col] + * if not npy_isnan(val): + * nonnans += 1 # <<<<<<<<<<<<<< + * if val != 0: + * nonzeros += 1 + */ + __pyx_v_nonnans = (__pyx_v_nonnans + 1); + + /* "Orange/distance/_distance.pyx":258 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * ps[col] = float(nonzeros) / nonnans + */ + __pyx_t_13 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_13) { + + /* "Orange/distance/_distance.pyx":259 + * nonnans += 1 + * if val != 0: + * nonzeros += 1 # <<<<<<<<<<<<<< + * ps[col] = float(nonzeros) / nonnans + * return {"ps": ps} + */ + __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); + + /* "Orange/distance/_distance.pyx":258 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * ps[col] = float(nonzeros) / nonnans + */ + } + + /* "Orange/distance/_distance.pyx":256 + * for row in range(len(x)): + * val = x[row, col] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: + */ + } + } + + /* "Orange/distance/_distance.pyx":260 + * if val != 0: + * nonzeros += 1 + * ps[col] = float(nonzeros) / nonnans # <<<<<<<<<<<<<< + * return {"ps": ps} + * + */ + __pyx_t_14 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_14 * __pyx_v_ps.strides[0]) )) = (((double)__pyx_v_nonzeros) / __pyx_v_nonnans); + } + + /* "Orange/distance/_distance.pyx":261 + * nonzeros += 1 + * ps[col] = float(nonzeros) / nonnans + * return {"ps": ps} # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_ps, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_ps, __pyx_t_1) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":244 + * + * + * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * cdef: + * int row, n_cols, nonzeros, nonnans + */ + + /* 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_XDECREF(__pyx_t_5); + __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.fit_jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":264 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_10jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10jaccard_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; + PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, 1); __PYX_ERR(0, 264, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, 2); __PYX_ERR(0, 264, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 264, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_fit_params = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 264, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 264, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 265, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_same; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_intersection; + double __pyx_v_union; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_3; + npy_intp __pyx_t_4; + npy_intp __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + __Pyx_RefNannySetupContext("jaccard_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 264, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 264, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":268 + * fit_params): + * cdef: + * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< + * char same = x1 is x2 + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ps = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":269 + * cdef: + * double [:] ps = fit_params["ps"] + * char same = x1 is x2 # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col + */ + __pyx_t_3 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); + __pyx_v_same = __pyx_t_3; + + /* "Orange/distance/_distance.pyx":276 + * double [:, :] distances + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == ps.shape[0] + */ + __pyx_t_4 = (__pyx_v_x1->dimensions[0]); + __pyx_t_5 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_4; + __pyx_v_n_cols = __pyx_t_5; + + /* "Orange/distance/_distance.pyx":277 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == ps.shape[0] + * + */ + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); + + /* "Orange/distance/_distance.pyx":278 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< + * + * distances = np.ones((n_rows1, n_rows2), dtype=float) + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_3 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_3) { + __pyx_t_3 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); + } + if (unlikely(!(__pyx_t_3 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 278, __pyx_L1_error) + } + } + #endif + + /* "Orange/distance/_distance.pyx":280 + * assert n_cols == x2.shape[1] == ps.shape[0] + * + * distances = np.ones((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; + + /* "Orange/distance/_distance.pyx":281 + * + * distances = np.ones((n_rows1, n_rows2), dtype=float) + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(row1 if same else n_rows2): + * intersection = union = 0 + */ + __pyx_t_10 = __pyx_v_n_rows1; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_row1 = __pyx_t_11; + + /* "Orange/distance/_distance.pyx":282 + * distances = np.ones((n_rows1, n_rows2), dtype=float) + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< + * intersection = union = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_same != 0)) { + __pyx_t_12 = __pyx_v_row1; + } else { + __pyx_t_12 = __pyx_v_n_rows2; + } + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row2 = __pyx_t_13; + + /* "Orange/distance/_distance.pyx":283 + * for row1 in range(n_rows1): + * for row2 in range(row1 if same else n_rows2): + * intersection = union = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] + */ + __pyx_v_intersection = 0.0; + __pyx_v_union = 0.0; + + /* "Orange/distance/_distance.pyx":284 + * for row2 in range(row1 if same else n_rows2): + * intersection = union = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): + */ + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":285 + * intersection = union = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_16 = __pyx_v_row1; + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row2; + __pyx_t_20 = __pyx_v_col; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; + + /* "Orange/distance/_distance.pyx":286 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + */ + __pyx_t_3 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":287 + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + */ + __pyx_t_3 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":288 + * if npy_isnan(val1): + * if npy_isnan(val2): + * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + */ + __pyx_t_22 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); + + /* "Orange/distance/_distance.pyx":289 + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< + * elif val2 != 0: + * intersection += ps[col] + */ + __pyx_t_23 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); + + /* "Orange/distance/_distance.pyx":287 + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":290 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + __pyx_t_3 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":291 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: + */ + __pyx_t_24 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":292 + * elif val2 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] + */ + __pyx_v_union = (__pyx_v_union + 1.0); + + /* "Orange/distance/_distance.pyx":290 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":294 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: + */ + /*else*/ { + __pyx_t_25 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L10:; + + /* "Orange/distance/_distance.pyx":286 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + */ + goto __pyx_L9; + } + + /* "Orange/distance/_distance.pyx":295 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] + */ + __pyx_t_3 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":296 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + __pyx_t_3 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":297 + * elif npy_isnan(val2): + * if val1 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: + */ + __pyx_t_26 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":298 + * if val1 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] + */ + __pyx_v_union = (__pyx_v_union + 1.0); + + /* "Orange/distance/_distance.pyx":296 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":300 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * else: + * if val1 != 0 and val2 != 0: + */ + /*else*/ { + __pyx_t_27 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L11:; + + /* "Orange/distance/_distance.pyx":295 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] + */ + goto __pyx_L9; + } + + /* "Orange/distance/_distance.pyx":302 + * union += ps[col] + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: + */ + /*else*/ { + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_3 = __pyx_t_28; + goto __pyx_L13_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_3 = __pyx_t_28; + __pyx_L13_bool_binop_done:; + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":303 + * else: + * if val1 != 0 and val2 != 0: + * intersection += 1 # <<<<<<<<<<<<<< + * if val1 != 0 or val2 != 0: + * union += 1 + */ + __pyx_v_intersection = (__pyx_v_intersection + 1.0); + + /* "Orange/distance/_distance.pyx":302 + * union += ps[col] + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: + */ + } + + /* "Orange/distance/_distance.pyx":304 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: + */ + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_28) { + } else { + __pyx_t_3 = __pyx_t_28; + goto __pyx_L16_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_3 = __pyx_t_28; + __pyx_L16_bool_binop_done:; + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":305 + * intersection += 1 + * if val1 != 0 or val2 != 0: + * union += 1 # <<<<<<<<<<<<<< + * if union != 0: + * distances[row1, row2] = 1 - intersection / union + */ + __pyx_v_union = (__pyx_v_union + 1.0); + + /* "Orange/distance/_distance.pyx":304 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: + */ + } + } + __pyx_L9:; + } + + /* "Orange/distance/_distance.pyx":306 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * + */ + __pyx_t_3 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":307 + * union += 1 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< + * + * if same: + */ + __pyx_t_29 = __pyx_v_row1; + __pyx_t_30 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + + /* "Orange/distance/_distance.pyx":306 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * + */ + } + } + } + + /* "Orange/distance/_distance.pyx":309 + * distances[row1, row2] = 1 - intersection / union + * + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + __pyx_t_3 = (__pyx_v_same != 0); + if (__pyx_t_3) { + + /* "Orange/distance/_distance.pyx":310 + * + * if same: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":309 + * distances[row1, row2] = 1 - intersection / union + * + * if same: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + } + + /* "Orange/distance/_distance.pyx":311 + * if same: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":264 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":314 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_12jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12jaccard_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("jaccard_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 314, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 314, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 314, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 314, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + int __pyx_v_in_both; + int __pyx_v_in_one; + int __pyx_v_in1_unk2; + int __pyx_v_unk1_in2; + int __pyx_v_unk1_unk2; + int __pyx_v_unk1_not2; + int __pyx_v_not1_unk2; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + __pyx_t_5numpy_float64_t __pyx_t_20; + int __pyx_t_21; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + double __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + __Pyx_RefNannySetupContext("jaccard_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 314, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":316 + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< + * + * int n_rows, n_cols, col1, col2, row + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ps = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":323 + * double [:, :] distances + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * distances = np.ones((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + */ + __pyx_t_3 = (__pyx_v_x->dimensions[0]); + __pyx_t_4 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":324 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.ones((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); + __pyx_t_1 = 0; + __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_8; + __pyx_t_8.memview = NULL; + __pyx_t_8.data = NULL; + + /* "Orange/distance/_distance.pyx":325 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.ones((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * in_both = in_one = 0 + */ + __pyx_t_9 = __pyx_v_n_cols; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_col1 = __pyx_t_10; + + /* "Orange/distance/_distance.pyx":326 + * distances = np.ones((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + */ + __pyx_t_11 = __pyx_v_col1; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_col2 = __pyx_t_12; + + /* "Orange/distance/_distance.pyx":327 + * for col1 in range(n_cols): + * for col2 in range(col1): + * in_both = in_one = 0 # <<<<<<<<<<<<<< + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + */ + __pyx_v_in_both = 0; + __pyx_v_in_one = 0; + + /* "Orange/distance/_distance.pyx":328 + * for col2 in range(col1): + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + */ + __pyx_v_in1_unk2 = 0; + __pyx_v_unk1_in2 = 0; + __pyx_v_unk1_unk2 = 0; + __pyx_v_unk1_not2 = 0; + __pyx_v_not1_unk2 = 0; + + /* "Orange/distance/_distance.pyx":329 + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + */ + __pyx_t_13 = __pyx_v_n_rows; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_v_row = __pyx_t_14; + + /* "Orange/distance/_distance.pyx":330 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col1; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_18 = __pyx_v_row; + __pyx_t_19 = __pyx_v_col2; + __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_17; + __pyx_v_val2 = __pyx_t_20; + + /* "Orange/distance/_distance.pyx":331 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 + */ + __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":332 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: + */ + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":333 + * if npy_isnan(val1): + * if npy_isnan(val2): + * unk1_unk2 += 1 # <<<<<<<<<<<<<< + * elif val2 != 0: + * unk1_in2 += 1 + */ + __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); + + /* "Orange/distance/_distance.pyx":332 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":334 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: + */ + __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":335 + * unk1_unk2 += 1 + * elif val2 != 0: + * unk1_in2 += 1 # <<<<<<<<<<<<<< + * else: + * unk1_not2 += 1 + */ + __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); + + /* "Orange/distance/_distance.pyx":334 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: + */ + goto __pyx_L10; + } + + /* "Orange/distance/_distance.pyx":337 + * unk1_in2 += 1 + * else: + * unk1_not2 += 1 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: + */ + /*else*/ { + __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); + } + __pyx_L10:; + + /* "Orange/distance/_distance.pyx":331 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 + */ + goto __pyx_L9; + } + + /* "Orange/distance/_distance.pyx":338 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 + */ + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":339 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":340 + * elif npy_isnan(val2): + * if val1 != 0: + * in1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * not1_unk2 += 1 + */ + __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + + /* "Orange/distance/_distance.pyx":339 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":342 + * in1_unk2 += 1 + * else: + * not1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * if val1 != 0 and val2 != 0: + */ + /*else*/ { + __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); + } + __pyx_L11:; + + /* "Orange/distance/_distance.pyx":338 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 + */ + goto __pyx_L9; + } + + /* "Orange/distance/_distance.pyx":344 + * not1_unk2 += 1 + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: + */ + /*else*/ { + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L13_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L13_bool_binop_done:; + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":345 + * else: + * if val1 != 0 and val2 != 0: + * in_both += 1 # <<<<<<<<<<<<<< + * elif val1 != 0 or val2 != 0: + * in_one += 1 + */ + __pyx_v_in_both = (__pyx_v_in_both + 1); + + /* "Orange/distance/_distance.pyx":344 + * not1_unk2 += 1 + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":346 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ + */ + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L15_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L15_bool_binop_done:; + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":347 + * in_both += 1 + * elif val1 != 0 or val2 != 0: + * in_one += 1 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + */ + __pyx_v_in_one = (__pyx_v_in_one + 1); + + /* "Orange/distance/_distance.pyx":346 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ + */ + } + __pyx_L12:; + } + __pyx_L9:; + } + + /* "Orange/distance/_distance.pyx":350 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ + */ + __pyx_t_23 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":351 + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + + */ + __pyx_t_24 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":352 + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + */ + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":354 + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + */ + __pyx_t_27 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":355 + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * return distances + */ + __pyx_t_28 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":356 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< + * return distances + */ + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":349 + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both # <<<<<<<<<<<<<< + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + */ + __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); + + /* "Orange/distance/_distance.pyx":348 + * elif val1 != 0 or val2 != 0: + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + */ + __pyx_t_32 = __pyx_v_col1; + __pyx_t_33 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + __pyx_t_34 = __pyx_v_col2; + __pyx_t_35 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + } + } + + /* "Orange/distance/_distance.pyx":357 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * return distances # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":314 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + goto __pyx_L4; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + /*else*/ { + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L6_bool_binop_done; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L6_bool_binop_done:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 218, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L9_bool_binop_done; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L9_bool_binop_done:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 222, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (__pyx_v_copy_shape != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_4 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + goto __pyx_L11; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + /*else*/ { + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L11:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef int offset + */ + __pyx_v_f = NULL; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef int offset + * + */ + __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L15_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L15_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + goto __pyx_L14; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + /*else*/ { + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L14:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L20_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_L20_next_or:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L19_bool_binop_done:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * if ((descr.byteorder == c'>' and little_endian) or + * (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" + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 259, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * (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" + */ + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = ((char *)"b"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * 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" + */ + case NPY_UBYTE: + __pyx_v_f = ((char *)"B"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 + * 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" + */ + case NPY_SHORT: + __pyx_v_f = ((char *)"h"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * 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" + */ + case NPY_USHORT: + __pyx_v_f = ((char *)"H"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 + * 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" + */ + case NPY_INT: + __pyx_v_f = ((char *)"i"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * 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" + */ + case NPY_UINT: + __pyx_v_f = ((char *)"I"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * 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" + */ + case NPY_LONG: + __pyx_v_f = ((char *)"l"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 + * 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" + */ + case NPY_ULONG: + __pyx_v_f = ((char *)"L"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * 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" + */ + case NPY_LONGLONG: + __pyx_v_f = ((char *)"q"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 + * 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" + */ + case NPY_ULONGLONG: + __pyx_v_f = ((char *)"Q"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * 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" + */ + case NPY_FLOAT: + __pyx_v_f = ((char *)"f"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 + * 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" + */ + case NPY_DOUBLE: + __pyx_v_f = ((char *)"d"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * 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" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = ((char *)"g"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 + * 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" + */ + case NPY_CFLOAT: + __pyx_v_f = ((char *)"Zf"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * 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" + */ + case NPY_CDOUBLE: + __pyx_v_f = ((char *)"Zd"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * 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: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = ((char *)"Zg"); + break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * 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) + */ + case NPY_OBJECT: + __pyx_v_f = ((char *)"O"); + break; + default: + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(1, 278, __pyx_L1_error) + break; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + /*else*/ { + __pyx_v_info->format = ((char *)malloc(0xFF)); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) + */ + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) + __pyx_v_f = __pyx_t_7; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * 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))) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 + * + * cdef dtype child + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * cdef dtype child + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(1, 794, __pyx_L1_error) + } + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 795, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 796, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (__pyx_t_6) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 799, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * 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 == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (__pyx_t_6) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 803, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 0x78; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_6) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 823, __pyx_L1_error) + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x68; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x69; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x6C; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x71; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x66; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x64; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x67; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x66; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x64; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x67; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + /*else*/ { + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 844, __pyx_L1_error) + } + __pyx_L15:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + goto __pyx_L13; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + /*else*/ { + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + goto __pyx_L3; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + /*else*/ { + Py_INCREF(__pyx_v_base); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + +/* Python wrapper */ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_shape = 0; + Py_ssize_t __pyx_v_itemsize; + PyObject *__pyx_v_format = 0; + PyObject *__pyx_v_mode = 0; + int __pyx_v_allocate_buffer; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)__pyx_n_s_c); + 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); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 120, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 120, __pyx_L3_error) + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 120, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_shape = ((PyObject*)values[0]); + __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 120, __pyx_L3_error) + __pyx_v_format = values[2]; + __pyx_v_mode = values[3]; + if (values[4]) { + __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 121, __pyx_L3_error) + } else { + + /* "View.MemoryView":121 + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, + * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<< + * + * cdef int idx + */ + __pyx_v_allocate_buffer = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 120, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 120, __pyx_L1_error) + if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 120, __pyx_L1_error) + } + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); + + /* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { + int __pyx_v_idx; + Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_dim; + PyObject **__pyx_v_p; + char __pyx_v_order; + int __pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + char *__pyx_t_6; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_INCREF(__pyx_v_format); + + /* "View.MemoryView":127 + * cdef PyObject **p + * + * self.ndim = len(shape) # <<<<<<<<<<<<<< + * self.itemsize = itemsize + * + */ + if (unlikely(__pyx_v_shape == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(2, 127, __pyx_L1_error) + } + __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 127, __pyx_L1_error) + __pyx_v_self->ndim = ((int)__pyx_t_1); + + /* "View.MemoryView":128 + * + * self.ndim = len(shape) + * self.itemsize = itemsize # <<<<<<<<<<<<<< + * + * if not self.ndim: + */ + __pyx_v_self->itemsize = __pyx_v_itemsize; + + /* "View.MemoryView":130 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") + * + */ + __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":131 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 131, __pyx_L1_error) + + /* "View.MemoryView":130 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") + * + */ + } + + /* "View.MemoryView":133 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") + * + */ + __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":134 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 134, __pyx_L1_error) + + /* "View.MemoryView":133 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") + * + */ + } + + /* "View.MemoryView":136 + * raise ValueError("itemsize <= 0 for cython.array") + * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + */ + __pyx_t_2 = PyBytes_Check(__pyx_v_format); + __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":137 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); + __pyx_t_5 = 0; + + /* "View.MemoryView":136 + * raise ValueError("itemsize <= 0 for cython.array") + * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + */ + } + + /* "View.MemoryView":138 + * if not isinstance(format, bytes): + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<< + * self.format = self._format + * + */ + if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(2, 138, __pyx_L1_error) + __pyx_t_5 = __pyx_v_format; + __Pyx_INCREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_v_self->_format); + __Pyx_DECREF(__pyx_v_self->_format); + __pyx_v_self->_format = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + /* "View.MemoryView":139 + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + * self.format = self._format # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(2, 139, __pyx_L1_error) + __pyx_v_self->format = __pyx_t_6; + + /* "View.MemoryView":142 + * + * + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<< + * self._strides = self._shape + self.ndim + * + */ + __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2))); + + /* "View.MemoryView":143 + * + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) + * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<< + * + * if not self._shape: + */ + __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim); + + /* "View.MemoryView":145 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") + * + */ + __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":146 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 146, __pyx_L1_error) + + /* "View.MemoryView":145 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") + * + */ + } + + /* "View.MemoryView":149 + * + * + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + */ + __pyx_t_7 = 0; + __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(2, 149, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 149, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 149, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_dim = __pyx_t_8; + __pyx_v_idx = __pyx_t_7; + __pyx_t_7 = (__pyx_t_7 + 1); + + /* "View.MemoryView":150 + * + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim + */ + __pyx_t_4 = ((__pyx_v_dim <= 0) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":151 + * for idx, dim in enumerate(shape): + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<< + * self._shape[idx] = dim + * + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9); + __pyx_t_3 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_Raise(__pyx_t_9, 0, 0, 0); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __PYX_ERR(2, 151, __pyx_L1_error) + + /* "View.MemoryView":150 + * + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim + */ + } + + /* "View.MemoryView":152 + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim # <<<<<<<<<<<<<< + * + * cdef char order + */ + (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim; + + /* "View.MemoryView":149 + * + * + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + */ + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "View.MemoryView":155 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' + */ + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 155, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":156 + * cdef char order + * if mode == 'fortran': + * order = b'F' # <<<<<<<<<<<<<< + * self.mode = u'fortran' + * elif mode == 'c': + */ + __pyx_v_order = 'F'; + + /* "View.MemoryView":157 + * if mode == 'fortran': + * order = b'F' + * self.mode = u'fortran' # <<<<<<<<<<<<<< + * elif mode == 'c': + * order = b'C' + */ + __Pyx_INCREF(__pyx_n_u_fortran); + __Pyx_GIVEREF(__pyx_n_u_fortran); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_fortran; + + /* "View.MemoryView":155 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' + */ + goto __pyx_L10; + } + + /* "View.MemoryView":158 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' + */ + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 158, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":159 + * self.mode = u'fortran' + * elif mode == 'c': + * order = b'C' # <<<<<<<<<<<<<< + * self.mode = u'c' + * else: + */ + __pyx_v_order = 'C'; + + /* "View.MemoryView":160 + * elif mode == 'c': + * order = b'C' + * self.mode = u'c' # <<<<<<<<<<<<<< + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + */ + __Pyx_INCREF(__pyx_n_u_c); + __Pyx_GIVEREF(__pyx_n_u_c); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_c; + + /* "View.MemoryView":158 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' + */ + goto __pyx_L10; + } + + /* "View.MemoryView":162 + * self.mode = u'c' + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<< + * + * self.len = fill_contig_strides_array(self._shape, self._strides, + */ + /*else*/ { + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 162, __pyx_L1_error) + } + __pyx_L10:; + + /* "View.MemoryView":164 + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + * + * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<< + * itemsize, self.ndim, order) + * + */ + __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order); + + /* "View.MemoryView":167 + * itemsize, self.ndim, order) + * + * self.free_data = allocate_buffer # <<<<<<<<<<<<<< + * self.dtype_is_object = format == b'O' + * if allocate_buffer: + */ + __pyx_v_self->free_data = __pyx_v_allocate_buffer; + + /* "View.MemoryView":168 + * + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<< + * if allocate_buffer: + * + */ + __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 168, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 168, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_self->dtype_is_object = __pyx_t_4; + + /* "View.MemoryView":169 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_4 = (__pyx_v_allocate_buffer != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":172 + * + * + * self.data = malloc(self.len) # <<<<<<<<<<<<<< + * if not self.data: + * raise MemoryError("unable to allocate array data.") + */ + __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len)); + + /* "View.MemoryView":173 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ + __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":174 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 174, __pyx_L1_error) + + /* "View.MemoryView":173 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ + } + + /* "View.MemoryView":176 + * raise MemoryError("unable to allocate array data.") + * + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":177 + * + * if self.dtype_is_object: + * p = self.data # <<<<<<<<<<<<<< + * for i in range(self.len / itemsize): + * p[i] = Py_None + */ + __pyx_v_p = ((PyObject **)__pyx_v_self->data); + + /* "View.MemoryView":178 + * if self.dtype_is_object: + * p = self.data + * for i in range(self.len / itemsize): # <<<<<<<<<<<<<< + * p[i] = Py_None + * Py_INCREF(Py_None) + */ + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(2, 178, __pyx_L1_error) + } + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(2, 178, __pyx_L1_error) + } + __pyx_t_1 = (__pyx_v_self->len / __pyx_v_itemsize); + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "View.MemoryView":179 + * p = self.data + * for i in range(self.len / itemsize): + * p[i] = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + (__pyx_v_p[__pyx_v_i]) = Py_None; + + /* "View.MemoryView":180 + * for i in range(self.len / itemsize): + * p[i] = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + Py_INCREF(Py_None); + } + + /* "View.MemoryView":176 + * raise MemoryError("unable to allocate array data.") + * + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + } + + /* "View.MemoryView":169 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_format); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":183 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_bufmode; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + char *__pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + Py_ssize_t *__pyx_t_7; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "View.MemoryView":184 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 # <<<<<<<<<<<<<< + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + */ + __pyx_v_bufmode = -1; + + /* "View.MemoryView":185 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + */ + __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 185, __pyx_L1_error) + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":186 + * cdef int bufmode = -1 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + */ + __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); + + /* "View.MemoryView":185 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + */ + goto __pyx_L3; + } + + /* "View.MemoryView":187 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + */ + __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 187, __pyx_L1_error) + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":188 + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") + */ + __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); + + /* "View.MemoryView":187 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + */ + } + __pyx_L3:; + + /* "View.MemoryView":189 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + */ + __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":190 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 190, __pyx_L1_error) + + /* "View.MemoryView":189 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + */ + } + + /* "View.MemoryView":191 + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data # <<<<<<<<<<<<<< + * info.len = self.len + * info.ndim = self.ndim + */ + __pyx_t_4 = __pyx_v_self->data; + __pyx_v_info->buf = __pyx_t_4; + + /* "View.MemoryView":192 + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + * info.len = self.len # <<<<<<<<<<<<<< + * info.ndim = self.ndim + * info.shape = self._shape + */ + __pyx_t_5 = __pyx_v_self->len; + __pyx_v_info->len = __pyx_t_5; + + /* "View.MemoryView":193 + * info.buf = self.data + * info.len = self.len + * info.ndim = self.ndim # <<<<<<<<<<<<<< + * info.shape = self._shape + * info.strides = self._strides + */ + __pyx_t_6 = __pyx_v_self->ndim; + __pyx_v_info->ndim = __pyx_t_6; + + /* "View.MemoryView":194 + * info.len = self.len + * info.ndim = self.ndim + * info.shape = self._shape # <<<<<<<<<<<<<< + * info.strides = self._strides + * info.suboffsets = NULL + */ + __pyx_t_7 = __pyx_v_self->_shape; + __pyx_v_info->shape = __pyx_t_7; + + /* "View.MemoryView":195 + * info.ndim = self.ndim + * info.shape = self._shape + * info.strides = self._strides # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = self.itemsize + */ + __pyx_t_7 = __pyx_v_self->_strides; + __pyx_v_info->strides = __pyx_t_7; + + /* "View.MemoryView":196 + * info.shape = self._shape + * info.strides = self._strides + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = self.itemsize + * info.readonly = 0 + */ + __pyx_v_info->suboffsets = NULL; + + /* "View.MemoryView":197 + * info.strides = self._strides + * info.suboffsets = NULL + * info.itemsize = self.itemsize # <<<<<<<<<<<<<< + * info.readonly = 0 + * + */ + __pyx_t_5 = __pyx_v_self->itemsize; + __pyx_v_info->itemsize = __pyx_t_5; + + /* "View.MemoryView":198 + * info.suboffsets = NULL + * info.itemsize = self.itemsize + * info.readonly = 0 # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + __pyx_v_info->readonly = 0; + + /* "View.MemoryView":200 + * info.readonly = 0 + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":201 + * + * if flags & PyBUF_FORMAT: + * info.format = self.format # <<<<<<<<<<<<<< + * else: + * info.format = NULL + */ + __pyx_t_4 = __pyx_v_self->format; + __pyx_v_info->format = __pyx_t_4; + + /* "View.MemoryView":200 + * info.readonly = 0 + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: + */ + goto __pyx_L5; + } + + /* "View.MemoryView":203 + * info.format = self.format + * else: + * info.format = NULL # <<<<<<<<<<<<<< + * + * info.obj = self + */ + /*else*/ { + __pyx_v_info->format = NULL; + } + __pyx_L5:; + + /* "View.MemoryView":205 + * info.format = NULL + * + * info.obj = self # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "View.MemoryView":183 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":209 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + * + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + */ + +/* Python wrapper */ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":210 + * + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: + */ + __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":211 + * def __dealloc__(array self): + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) # <<<<<<<<<<<<<< + * elif self.free_data: + * if self.dtype_is_object: + */ + __pyx_v_self->callback_free_data(__pyx_v_self->data); + + /* "View.MemoryView":210 + * + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":212 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, + */ + __pyx_t_1 = (__pyx_v_self->free_data != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":213 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + */ + __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":214 + * elif self.free_data: + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<< + * self._strides, self.ndim, False) + * free(self.data) + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0); + + /* "View.MemoryView":213 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + */ + } + + /* "View.MemoryView":216 + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + * free(self.data) # <<<<<<<<<<<<<< + * PyObject_Free(self._shape) + * + */ + free(__pyx_v_self->data); + + /* "View.MemoryView":212 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, + */ + } + __pyx_L3:; + + /* "View.MemoryView":217 + * self._strides, self.ndim, False) + * free(self.data) + * PyObject_Free(self._shape) # <<<<<<<<<<<<<< + * + * @property + */ + PyObject_Free(__pyx_v_self->_shape); + + /* "View.MemoryView":209 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + * + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":220 + * + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":221 + * @property + * def memview(self): + * return self.get_memview() # <<<<<<<<<<<<<< + * + * @cname('get_memview') + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":220 + * + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":224 + * + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) + */ + +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) { + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_memview", 0); + + /* "View.MemoryView":225 + * @cname('get_memview') + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<< + * return memoryview(self, flags, self.dtype_is_object) + * + */ + __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE); + + /* "View.MemoryView":226 + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __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; + goto __pyx_L0; + + /* "View.MemoryView":224 + * + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":229 + * + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__getattr__", 0); + + /* "View.MemoryView":230 + * + * def __getattr__(self, attr): + * return getattr(self.memview, attr) # <<<<<<<<<<<<<< + * + * def __getitem__(self, item): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":229 + * + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":232 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] + * + */ + +/* Python wrapper */ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "View.MemoryView":233 + * + * def __getitem__(self, item): + * return self.memview[item] # <<<<<<<<<<<<<< + * + * def __setitem__(self, item, value): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":232 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":235 + * return self.memview[item] + * + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value + * + */ + +/* Python wrapper */ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setitem__", 0); + + /* "View.MemoryView":236 + * + * def __setitem__(self, item, value): + * self.memview[item] = value # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 236, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "View.MemoryView":235 + * return self.memview[item] + * + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":240 + * + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result + */ + +static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { + struct __pyx_array_obj *__pyx_v_result = 0; + struct __pyx_array_obj *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("array_cwrapper", 0); + + /* "View.MemoryView":244 + * cdef array result + * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + */ + __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":245 + * + * if buf == NULL: + * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), + */ + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "View.MemoryView":244 + * cdef array result + * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":247 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf + */ + /*else*/ { + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_3 = 0; + + /* "View.MemoryView":248 + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) # <<<<<<<<<<<<<< + * result.data = buf + * + */ + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 248, __pyx_L1_error) + + /* "View.MemoryView":247 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf + */ + __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "View.MemoryView":249 + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) + * result.data = buf # <<<<<<<<<<<<<< + * + * return result + */ + __pyx_v_result->data = __pyx_v_buf; + } + __pyx_L3:; + + /* "View.MemoryView":251 + * result.data = buf + * + * return result # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + /* "View.MemoryView":240 + * + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":277 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): + */ + +/* Python wrapper */ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_name = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; + PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 277, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_name = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 277, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "View.MemoryView":278 + * cdef object name + * def __init__(self, name): + * self.name = name # <<<<<<<<<<<<<< + * def __repr__(self): + * return self.name + */ + __Pyx_INCREF(__pyx_v_name); + __Pyx_GIVEREF(__pyx_v_name); + __Pyx_GOTREF(__pyx_v_self->name); + __Pyx_DECREF(__pyx_v_self->name); + __pyx_v_self->name = __pyx_v_name; + + /* "View.MemoryView":277 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): + */ + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":279 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name + * + */ + +/* Python wrapper */ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "View.MemoryView":280 + * self.name = name + * def __repr__(self): + * return self.name # <<<<<<<<<<<<<< + * + * cdef generic = Enum("") + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->name); + __pyx_r = __pyx_v_self->name; + goto __pyx_L0; + + /* "View.MemoryView":279 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":294 + * + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory + */ + +static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) { + Py_intptr_t __pyx_v_aligned_p; + size_t __pyx_v_offset; + void *__pyx_r; + int __pyx_t_1; + + /* "View.MemoryView":296 + * cdef void *align_pointer(void *memory, size_t alignment) nogil: + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<< + * cdef size_t offset + * + */ + __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory); + + /* "View.MemoryView":300 + * + * with cython.cdivision(True): + * offset = aligned_p % alignment # <<<<<<<<<<<<<< + * + * if offset > 0: + */ + __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment); + + /* "View.MemoryView":302 + * offset = aligned_p % alignment + * + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset + * + */ + __pyx_t_1 = ((__pyx_v_offset > 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":303 + * + * if offset > 0: + * aligned_p += alignment - offset # <<<<<<<<<<<<<< + * + * return aligned_p + */ + __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset)); + + /* "View.MemoryView":302 + * offset = aligned_p % alignment + * + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset + * + */ + } + + /* "View.MemoryView":305 + * aligned_p += alignment - offset + * + * return aligned_p # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = ((void *)__pyx_v_aligned_p); + goto __pyx_L0; + + /* "View.MemoryView":294 + * + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":341 + * cdef __Pyx_TypeInfo *typeinfo + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags + */ + +/* Python wrapper */ +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_obj = 0; + int __pyx_v_flags; + int __pyx_v_dtype_is_object; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0}; + PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 341, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 341, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_obj = values[0]; + __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) + if (values[2]) { + __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) + } else { + __pyx_v_dtype_is_object = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 341, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "View.MemoryView":342 + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj # <<<<<<<<<<<<<< + * self.flags = flags + * if type(self) is memoryview or obj is not None: + */ + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + __Pyx_GOTREF(__pyx_v_self->obj); + __Pyx_DECREF(__pyx_v_self->obj); + __pyx_v_self->obj = __pyx_v_obj; + + /* "View.MemoryView":343 + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj + * self.flags = flags # <<<<<<<<<<<<<< + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + */ + __pyx_v_self->flags = __pyx_v_flags; + + /* "View.MemoryView":344 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + */ + __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type)); + __pyx_t_3 = (__pyx_t_2 != 0); + if (!__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_3 = (__pyx_v_obj != Py_None); + __pyx_t_2 = (__pyx_t_3 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + /* "View.MemoryView":345 + * self.flags = flags + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<< + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None + */ + __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 345, __pyx_L1_error) + + /* "View.MemoryView":346 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) + */ + __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":347 + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None; + + /* "View.MemoryView":348 + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * global __pyx_memoryview_thread_locks_used + */ + Py_INCREF(Py_None); + + /* "View.MemoryView":346 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) + */ + } + + /* "View.MemoryView":344 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + */ + } + + /* "View.MemoryView":351 + * + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + */ + __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":352 + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: + */ + __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + + /* "View.MemoryView":353 + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<< + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1); + + /* "View.MemoryView":351 + * + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + */ + } + + /* "View.MemoryView":354 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":355 + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<< + * if self.lock is NULL: + * raise MemoryError + */ + __pyx_v_self->lock = PyThread_allocate_lock(); + + /* "View.MemoryView":356 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * + */ + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":357 + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + PyErr_NoMemory(); __PYX_ERR(2, 357, __pyx_L1_error) + + /* "View.MemoryView":356 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * + */ + } + + /* "View.MemoryView":354 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ + } + + /* "View.MemoryView":359 + * raise MemoryError + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":360 + * + * if flags & PyBUF_FORMAT: + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<< + * else: + * self.dtype_is_object = dtype_is_object + */ + __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_self->dtype_is_object = __pyx_t_1; + + /* "View.MemoryView":359 + * raise MemoryError + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + */ + goto __pyx_L10; + } + + /* "View.MemoryView":362 + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<< + * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + */ + /*else*/ { + __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object; + } + __pyx_L10:; + + /* "View.MemoryView":364 + * self.dtype_is_object = dtype_is_object + * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<< + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL + */ + __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int)))); + + /* "View.MemoryView":366 + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL # <<<<<<<<<<<<<< + * + * def __dealloc__(memoryview self): + */ + __pyx_v_self->typeinfo = NULL; + + /* "View.MemoryView":341 + * cdef __Pyx_TypeInfo *typeinfo + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":368 + * self.typeinfo = NULL + * + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + */ + +/* Python wrapper */ +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + PyThread_type_lock __pyx_t_5; + PyThread_type_lock __pyx_t_6; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":369 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) + * + */ + __pyx_t_1 = (__pyx_v_self->obj != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":370 + * def __dealloc__(memoryview self): + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<< + * + * cdef int i + */ + __Pyx_ReleaseBuffer((&__pyx_v_self->view)); + + /* "View.MemoryView":369 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) + * + */ + } + + /* "View.MemoryView":374 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + */ + __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":375 + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<< + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + */ + __pyx_t_3 = __pyx_memoryview_thread_locks_used; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "View.MemoryView":376 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + */ + __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":377 + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<< + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1); + + /* "View.MemoryView":378 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + */ + __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":380 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<< + * break + * else: + */ + __pyx_t_5 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_v_i]); + + /* "View.MemoryView":379 + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break + */ + (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_5; + (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_6; + + /* "View.MemoryView":378 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + */ + } + + /* "View.MemoryView":381 + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break # <<<<<<<<<<<<<< + * else: + * PyThread_free_lock(self.lock) + */ + goto __pyx_L6_break; + + /* "View.MemoryView":376 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + */ + } + } + /*else*/ { + + /* "View.MemoryView":383 + * break + * else: + * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<< + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: + */ + PyThread_free_lock(__pyx_v_self->lock); + } + __pyx_L6_break:; + + /* "View.MemoryView":374 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + */ + } + + /* "View.MemoryView":368 + * self.typeinfo = NULL + * + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":385 + * PyThread_free_lock(self.lock) + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf + */ + +static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + Py_ssize_t __pyx_v_dim; + char *__pyx_v_itemp; + PyObject *__pyx_v_idx = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + char *__pyx_t_7; + __Pyx_RefNannySetupContext("get_item_pointer", 0); + + /* "View.MemoryView":387 + * cdef char *get_item_pointer(memoryview self, object index) except NULL: + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<< + * + * for dim, idx in enumerate(index): + */ + __pyx_v_itemp = ((char *)__pyx_v_self->view.buf); + + /* "View.MemoryView":389 + * cdef char *itemp = self.view.buf + * + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + */ + __pyx_t_1 = 0; + if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) { + __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 389, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 389, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_v_dim = __pyx_t_1; + __pyx_t_1 = (__pyx_t_1 + 1); + + /* "View.MemoryView":390 + * + * for dim, idx in enumerate(index): + * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<< + * + * return itemp + */ + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 390, __pyx_L1_error) + __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(2, 390, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_7; + + /* "View.MemoryView":389 + * cdef char *itemp = self.view.buf + * + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + */ + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":392 + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + * return itemp # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_itemp; + goto __pyx_L0; + + /* "View.MemoryView":385 + * PyThread_free_lock(self.lock) + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":395 + * + * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_indices = NULL; + char *__pyx_v_itemp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + char *__pyx_t_6; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "View.MemoryView":396 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self + * + */ + __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":397 + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: + * return self # <<<<<<<<<<<<<< + * + * have_slices, indices = _unellipsify(index, self.view.ndim) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + /* "View.MemoryView":396 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self + * + */ + } + + /* "View.MemoryView":399 + * return self + * + * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + * + * cdef char *itemp + */ + __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (likely(__pyx_t_3 != Py_None)) { + PyObject* sequence = __pyx_t_3; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(2, 399, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + #else + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 399, __pyx_L1_error) + } + __pyx_v_have_slices = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_v_indices = __pyx_t_5; + __pyx_t_5 = 0; + + /* "View.MemoryView":402 + * + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: + */ + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 402, __pyx_L1_error) + if (__pyx_t_2) { + + /* "View.MemoryView":403 + * cdef char *itemp + * if have_slices: + * return memview_slice(self, indices) # <<<<<<<<<<<<<< + * else: + * itemp = self.get_item_pointer(indices) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":402 + * + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: + */ + } + + /* "View.MemoryView":405 + * return memview_slice(self, indices) + * else: + * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<< + * return self.convert_item_to_object(itemp) + * + */ + /*else*/ { + __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 405, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_6; + + /* "View.MemoryView":406 + * else: + * itemp = self.get_item_pointer(indices) + * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<< + * + * def __setitem__(memoryview self, object index, object value): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 406, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":395 + * + * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_indices); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":408 + * return self.convert_item_to_object(itemp) + * + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * have_slices, index = _unellipsify(index, self.view.ndim) + * + */ + +/* Python wrapper */ +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_obj = NULL; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__setitem__", 0); + __Pyx_INCREF(__pyx_v_index); + + /* "View.MemoryView":409 + * + * def __setitem__(memoryview self, object index, object value): + * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + * + * if have_slices: + */ + __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(__pyx_t_1 != Py_None)) { + PyObject* sequence = __pyx_t_1; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(2, 409, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + #else + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 409, __pyx_L1_error) + } + __pyx_v_have_slices = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":411 + * have_slices, index = _unellipsify(index, self.view.ndim) + * + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 411, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":412 + * + * if have_slices: + * obj = self.is_slice(value) # <<<<<<<<<<<<<< + * if obj: + * self.setitem_slice_assignment(self[index], obj) + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 412, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_obj = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":413 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 413, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":414 + * obj = self.is_slice(value) + * if obj: + * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<< + * else: + * self.setitem_slice_assign_scalar(self[index], value) + */ + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 414, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 414, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":413 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + goto __pyx_L4; + } + + /* "View.MemoryView":416 + * self.setitem_slice_assignment(self[index], obj) + * else: + * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<< + * else: + * self.setitem_indexed(index, value) + */ + /*else*/ { + __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 416, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 416, __pyx_L1_error) + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 416, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L4:; + + /* "View.MemoryView":411 + * have_slices, index = _unellipsify(index, self.view.ndim) + * + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":418 + * self.setitem_slice_assign_scalar(self[index], value) + * else: + * self.setitem_indexed(index, value) # <<<<<<<<<<<<<< + * + * cdef is_slice(self, obj): + */ + /*else*/ { + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 418, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":408 + * return self.convert_item_to_object(itemp) + * + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * have_slices, index = _unellipsify(index, self.view.ndim) + * + */ + + /* 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_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_obj); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":420 + * self.setitem_indexed(index, value) + * + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: + */ + +static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + __Pyx_RefNannySetupContext("is_slice", 0); + __Pyx_INCREF(__pyx_v_obj); + + /* "View.MemoryView":421 + * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + */ + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + /*try:*/ { + + /* "View.MemoryView":423 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: + */ + __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_6); + + /* "View.MemoryView":424 + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) # <<<<<<<<<<<<<< + * except TypeError: + * return None + */ + __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 424, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); + + /* "View.MemoryView":423 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: + */ + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7); + __pyx_t_7 = 0; + + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + } + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L11_try_end; + __pyx_L4_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "View.MemoryView":425 + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + * except TypeError: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); + if (__pyx_t_9) { + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 425, __pyx_L6_except_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GOTREF(__pyx_t_6); + + /* "View.MemoryView":426 + * self.dtype_is_object) + * except TypeError: + * return None # <<<<<<<<<<<<<< + * + * return obj + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L7_except_return; + } + goto __pyx_L6_except_error; + __pyx_L6_except_error:; + + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L1_error; + __pyx_L7_except_return:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L0; + __pyx_L11_try_end:; + } + + /* "View.MemoryView":421 + * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + */ + } + + /* "View.MemoryView":428 + * return None + * + * return obj # <<<<<<<<<<<<<< + * + * cdef setitem_slice_assignment(self, dst, src): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_obj); + __pyx_r = __pyx_v_obj; + goto __pyx_L0; + + /* "View.MemoryView":420 + * self.setitem_indexed(index, value) + * + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_obj); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":430 + * return obj + * + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice + */ + +static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) { + __Pyx_memviewslice __pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_src_slice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("setitem_slice_assignment", 0); + + /* "View.MemoryView":434 + * cdef __Pyx_memviewslice src_slice + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) + */ + if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 434, __pyx_L1_error) + + /* "View.MemoryView":435 + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<< + * src.ndim, dst.ndim, self.dtype_is_object) + * + */ + if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 435, __pyx_L1_error) + + /* "View.MemoryView":436 + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<< + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "View.MemoryView":434 + * cdef __Pyx_memviewslice src_slice + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) + */ + __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 434, __pyx_L1_error) + + /* "View.MemoryView":430 + * return obj + * + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":438 + * src.ndim, dst.ndim, self.dtype_is_object) + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL + */ + +static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { + int __pyx_v_array[0x80]; + void *__pyx_v_tmp; + void *__pyx_v_item; + __Pyx_memviewslice *__pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_tmp_slice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + char const *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0); + + /* "View.MemoryView":440 + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + * cdef int array[128] + * cdef void *tmp = NULL # <<<<<<<<<<<<<< + * cdef void *item + * + */ + __pyx_v_tmp = NULL; + + /* "View.MemoryView":445 + * cdef __Pyx_memviewslice *dst_slice + * cdef __Pyx_memviewslice tmp_slice + * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<< + * + * if self.view.itemsize > sizeof(array): + */ + __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); + + /* "View.MemoryView":447 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) + * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + */ + __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":448 + * + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<< + * if tmp == NULL: + * raise MemoryError + */ + __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize); + + /* "View.MemoryView":449 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp + */ + __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":450 + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * item = tmp + * else: + */ + PyErr_NoMemory(); __PYX_ERR(2, 450, __pyx_L1_error) + + /* "View.MemoryView":449 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp + */ + } + + /* "View.MemoryView":451 + * if tmp == NULL: + * raise MemoryError + * item = tmp # <<<<<<<<<<<<<< + * else: + * item = array + */ + __pyx_v_item = __pyx_v_tmp; + + /* "View.MemoryView":447 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) + * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":453 + * item = tmp + * else: + * item = array # <<<<<<<<<<<<<< + * + * try: + */ + /*else*/ { + __pyx_v_item = ((void *)__pyx_v_array); + } + __pyx_L3:; + + /* "View.MemoryView":455 + * item = array + * + * try: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * ( item)[0] = value + */ + /*try:*/ { + + /* "View.MemoryView":456 + * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: + */ + __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":457 + * try: + * if self.dtype_is_object: + * ( item)[0] = value # <<<<<<<<<<<<<< + * else: + * self.assign_item_from_object( item, value) + */ + (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value); + + /* "View.MemoryView":456 + * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: + */ + goto __pyx_L8; + } + + /* "View.MemoryView":459 + * ( item)[0] = value + * else: + * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 459, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_L8:; + + /* "View.MemoryView":463 + * + * + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + */ + __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":464 + * + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<< + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + * item, self.dtype_is_object) + */ + __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 464, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":463 + * + * + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + */ + } + + /* "View.MemoryView":465 + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<< + * item, self.dtype_is_object) + * finally: + */ + __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object); + } + + /* "View.MemoryView":468 + * item, self.dtype_is_object) + * finally: + * PyMem_Free(tmp) # <<<<<<<<<<<<<< + * + * cdef setitem_indexed(self, index, value): + */ + /*finally:*/ { + /*normal exit:*/{ + PyMem_Free(__pyx_v_tmp); + goto __pyx_L7; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L6_error:; + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename; + { + PyMem_Free(__pyx_v_tmp); + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); + } + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8); + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; + __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5; + goto __pyx_L1_error; + } + __pyx_L7:; + } + + /* "View.MemoryView":438 + * src.ndim, dst.ndim, self.dtype_is_object) + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":470 + * PyMem_Free(tmp) + * + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) + */ + +static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + char *__pyx_v_itemp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + char *__pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("setitem_indexed", 0); + + /* "View.MemoryView":471 + * + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<< + * self.assign_item_from_object(itemp, value) + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(2, 471, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_1; + + /* "View.MemoryView":472 + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<< + * + * cdef convert_item_to_object(self, char *itemp): + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":470 + * PyMem_Free(tmp) + * + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":474 + * self.assign_item_from_object(itemp, value) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + +static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_v_struct = NULL; + PyObject *__pyx_v_bytesitem = 0; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + size_t __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + __Pyx_RefNannySetupContext("convert_item_to_object", 0); + + /* "View.MemoryView":477 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef bytes bytesitem + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 477, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":480 + * cdef bytes bytesitem + * + * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<< + * try: + * result = struct.unpack(self.view.format, bytesitem) + */ + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 480, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_bytesitem = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":481 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + /*try:*/ { + + /* "View.MemoryView":482 + * bytesitem = itemp[:self.view.itemsize] + * try: + * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<< + * except struct.error: + * raise ValueError("Unable to convert item to object") + */ + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_8 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); + __Pyx_INCREF(__pyx_v_bytesitem); + __Pyx_GIVEREF(__pyx_v_bytesitem); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":481 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + } + + /* "View.MemoryView":486 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + /*else:*/ { + __pyx_t_10 = strlen(__pyx_v_self->view.format); + __pyx_t_11 = ((__pyx_t_10 == 1) != 0); + if (__pyx_t_11) { + + /* "View.MemoryView":487 + * else: + * if len(self.view.format) == 1: + * return result[0] # <<<<<<<<<<<<<< + * return result + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 487, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L6_except_return; + + /* "View.MemoryView":486 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + } + + /* "View.MemoryView":488 + * if len(self.view.format) == 1: + * return result[0] + * return result # <<<<<<<<<<<<<< + * + * cdef assign_item_from_object(self, char *itemp, object value): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L6_except_return; + } + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "View.MemoryView":483 + * try: + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: # <<<<<<<<<<<<<< + * raise ValueError("Unable to convert item to object") + * else: + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 483, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_12) { + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(2, 483, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_9); + + /* "View.MemoryView":484 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(2, 484, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "View.MemoryView":481 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L1_error; + __pyx_L6_except_return:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L0; + } + + /* "View.MemoryView":474 + * self.assign_item_from_object(itemp, value) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesitem); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":490 + * return result + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + +static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_v_struct = NULL; + char __pyx_v_c; + PyObject *__pyx_v_bytesvalue = 0; + Py_ssize_t __pyx_v_i; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + char *__pyx_t_10; + char *__pyx_t_11; + char *__pyx_t_12; + char *__pyx_t_13; + __Pyx_RefNannySetupContext("assign_item_from_object", 0); + + /* "View.MemoryView":493 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef char c + * cdef bytes bytesvalue + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":498 + * cdef Py_ssize_t i + * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: + */ + __pyx_t_2 = PyTuple_Check(__pyx_v_value); + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":499 + * + * if isinstance(value, tuple): + * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<< + * else: + * bytesvalue = struct.pack(self.view.format, value) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 499, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "View.MemoryView":498 + * cdef Py_ssize_t i + * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":501 + * bytesvalue = struct.pack(self.view.format, *value) + * else: + * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<< + * + * for i, c in enumerate(bytesvalue): + */ + /*else*/ { + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_7 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_7 = 1; + } + } + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 501, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":503 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c + * + */ + __pyx_t_7 = 0; + if (unlikely(__pyx_v_bytesvalue == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); + __PYX_ERR(2, 503, __pyx_L1_error) + } + __Pyx_INCREF(__pyx_v_bytesvalue); + __pyx_t_9 = __pyx_v_bytesvalue; + __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9); + __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9)); + for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) { + __pyx_t_10 = __pyx_t_13; + __pyx_v_c = (__pyx_t_10[0]); + + /* "View.MemoryView":504 + * + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + __pyx_v_i = __pyx_t_7; + + /* "View.MemoryView":503 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c + * + */ + __pyx_t_7 = (__pyx_t_7 + 1); + + /* "View.MemoryView":504 + * + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "View.MemoryView":490 + * return result + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesvalue); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":507 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + Py_ssize_t *__pyx_t_2; + char *__pyx_t_3; + void *__pyx_t_4; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "View.MemoryView":508 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.shape = self.view.shape + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":509 + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape # <<<<<<<<<<<<<< + * else: + * info.shape = NULL + */ + __pyx_t_2 = __pyx_v_self->view.shape; + __pyx_v_info->shape = __pyx_t_2; + + /* "View.MemoryView":508 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.shape = self.view.shape + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":511 + * info.shape = self.view.shape + * else: + * info.shape = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_STRIDES: + */ + /*else*/ { + __pyx_v_info->shape = NULL; + } + __pyx_L3:; + + /* "View.MemoryView":513 + * info.shape = NULL + * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":514 + * + * if flags & PyBUF_STRIDES: + * info.strides = self.view.strides # <<<<<<<<<<<<<< + * else: + * info.strides = NULL + */ + __pyx_t_2 = __pyx_v_self->view.strides; + __pyx_v_info->strides = __pyx_t_2; + + /* "View.MemoryView":513 + * info.shape = NULL + * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: + */ + goto __pyx_L4; + } + + /* "View.MemoryView":516 + * info.strides = self.view.strides + * else: + * info.strides = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_INDIRECT: + */ + /*else*/ { + __pyx_v_info->strides = NULL; + } + __pyx_L4:; + + /* "View.MemoryView":518 + * info.strides = NULL + * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":519 + * + * if flags & PyBUF_INDIRECT: + * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<< + * else: + * info.suboffsets = NULL + */ + __pyx_t_2 = __pyx_v_self->view.suboffsets; + __pyx_v_info->suboffsets = __pyx_t_2; + + /* "View.MemoryView":518 + * info.strides = NULL + * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: + */ + goto __pyx_L5; + } + + /* "View.MemoryView":521 + * info.suboffsets = self.view.suboffsets + * else: + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + /*else*/ { + __pyx_v_info->suboffsets = NULL; + } + __pyx_L5:; + + /* "View.MemoryView":523 + * info.suboffsets = NULL + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":524 + * + * if flags & PyBUF_FORMAT: + * info.format = self.view.format # <<<<<<<<<<<<<< + * else: + * info.format = NULL + */ + __pyx_t_3 = __pyx_v_self->view.format; + __pyx_v_info->format = __pyx_t_3; + + /* "View.MemoryView":523 + * info.suboffsets = NULL + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: + */ + goto __pyx_L6; + } + + /* "View.MemoryView":526 + * info.format = self.view.format + * else: + * info.format = NULL # <<<<<<<<<<<<<< + * + * info.buf = self.view.buf + */ + /*else*/ { + __pyx_v_info->format = NULL; + } + __pyx_L6:; + + /* "View.MemoryView":528 + * info.format = NULL + * + * info.buf = self.view.buf # <<<<<<<<<<<<<< + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize + */ + __pyx_t_4 = __pyx_v_self->view.buf; + __pyx_v_info->buf = __pyx_t_4; + + /* "View.MemoryView":529 + * + * info.buf = self.view.buf + * info.ndim = self.view.ndim # <<<<<<<<<<<<<< + * info.itemsize = self.view.itemsize + * info.len = self.view.len + */ + __pyx_t_5 = __pyx_v_self->view.ndim; + __pyx_v_info->ndim = __pyx_t_5; + + /* "View.MemoryView":530 + * info.buf = self.view.buf + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<< + * info.len = self.view.len + * info.readonly = 0 + */ + __pyx_t_6 = __pyx_v_self->view.itemsize; + __pyx_v_info->itemsize = __pyx_t_6; + + /* "View.MemoryView":531 + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize + * info.len = self.view.len # <<<<<<<<<<<<<< + * info.readonly = 0 + * info.obj = self + */ + __pyx_t_6 = __pyx_v_self->view.len; + __pyx_v_info->len = __pyx_t_6; + + /* "View.MemoryView":532 + * info.itemsize = self.view.itemsize + * info.len = self.view.len + * info.readonly = 0 # <<<<<<<<<<<<<< + * info.obj = self + * + */ + __pyx_v_info->readonly = 0; + + /* "View.MemoryView":533 + * info.len = self.view.len + * info.readonly = 0 + * info.obj = self # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "View.MemoryView":507 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape + */ + + /* function exit code */ + __pyx_r = 0; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":539 + * + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":540 + * @property + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<< + * transpose_memslice(&result.from_slice) + * return result + */ + __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 540, __pyx_L1_error) + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":541 + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 541, __pyx_L1_error) + + /* "View.MemoryView":542 + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + * return result # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":539 + * + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":545 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":546 + * @property + * def base(self): + * return self.obj # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->obj); + __pyx_r = __pyx_v_self->obj; + goto __pyx_L0; + + /* "View.MemoryView":545 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":549 + * + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_length; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":550 + * @property + * def shape(self): + * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { + __pyx_t_2 = __pyx_t_4; + __pyx_v_length = (__pyx_t_2[0]); + __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "View.MemoryView":549 + * + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":553 + * + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_stride; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":554 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") + */ + __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":556 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + */ + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(2, 556, __pyx_L1_error) + + /* "View.MemoryView":554 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") + */ + } + + /* "View.MemoryView":558 + * raise ValueError("Buffer view does not expose strides") + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_v_stride = (__pyx_t_3[0]); + __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L0; + + /* "View.MemoryView":553 + * + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":561 + * + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + Py_ssize_t *__pyx_t_6; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":562 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim + * + */ + __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":563 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__16, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":562 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim + * + */ + } + + /* "View.MemoryView":565 + * return (-1,) * self.view.ndim + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); + for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { + __pyx_t_4 = __pyx_t_6; + __pyx_v_suboffset = (__pyx_t_4[0]); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __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; + goto __pyx_L0; + + /* "View.MemoryView":561 + * + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":568 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":569 + * @property + * def ndim(self): + * return self.view.ndim # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 569, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":568 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":572 + * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":573 + * @property + * def itemsize(self): + * return self.view.itemsize # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 573, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":572 + * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":576 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":577 + * @property + * def nbytes(self): + * return self.size * self.view.itemsize # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":576 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":580 + * + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":581 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 + * + */ + __pyx_t_1 = (__pyx_v_self->_size == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":582 + * def size(self): + * if self._size is None: + * result = 1 # <<<<<<<<<<<<<< + * + * for length in self.view.shape[:self.view.ndim]: + */ + __Pyx_INCREF(__pyx_int_1); + __pyx_v_result = __pyx_int_1; + + /* "View.MemoryView":584 + * result = 1 + * + * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< + * result *= length + * + */ + __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 584, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); + __pyx_t_6 = 0; + + /* "View.MemoryView":585 + * + * for length in self.view.shape[:self.view.ndim]: + * result *= length # <<<<<<<<<<<<<< + * + * self._size = result + */ + __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 585, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); + __pyx_t_6 = 0; + } + + /* "View.MemoryView":587 + * result *= length + * + * self._size = result # <<<<<<<<<<<<<< + * + * return self._size + */ + __Pyx_INCREF(__pyx_v_result); + __Pyx_GIVEREF(__pyx_v_result); + __Pyx_GOTREF(__pyx_v_self->_size); + __Pyx_DECREF(__pyx_v_self->_size); + __pyx_v_self->_size = __pyx_v_result; + + /* "View.MemoryView":581 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 + * + */ + } + + /* "View.MemoryView":589 + * self._size = result + * + * return self._size # <<<<<<<<<<<<<< + * + * def __len__(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_size); + __pyx_r = __pyx_v_self->_size; + goto __pyx_L0; + + /* "View.MemoryView":580 + * + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":591 + * return self._size + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] + */ + +/* Python wrapper */ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__len__", 0); + + /* "View.MemoryView":592 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * + */ + __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":593 + * def __len__(self): + * if self.view.ndim >= 1: + * return self.view.shape[0] # <<<<<<<<<<<<<< + * + * return 0 + */ + __pyx_r = (__pyx_v_self->view.shape[0]); + goto __pyx_L0; + + /* "View.MemoryView":592 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * + */ + } + + /* "View.MemoryView":595 + * return self.view.shape[0] + * + * return 0 # <<<<<<<<<<<<<< + * + * def __repr__(self): + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":591 + * return self._size + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":597 + * return 0 + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "View.MemoryView":598 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":599 + * def __repr__(self): + * return "" % (self.base.__class__.__name__, + * id(self)) # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 599, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 599, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":598 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) + * + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":597 + * return 0 + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":601 + * id(self)) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "View.MemoryView":602 + * + * def __str__(self): + * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":601 + * id(self)) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":605 + * + * + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("is_c_contig", 0); + + /* "View.MemoryView":608 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + */ + __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); + + /* "View.MemoryView":609 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<< + * + * def is_f_contig(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 609, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":605 + * + * + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":611 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("is_f_contig", 0); + + /* "View.MemoryView":614 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + */ + __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); + + /* "View.MemoryView":615 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<< + * + * def copy(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 615, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":611 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":617 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_mslice; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("copy", 0); + + /* "View.MemoryView":619 + * def copy(self): + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<< + * + * slice_copy(self, &mslice) + */ + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS)); + + /* "View.MemoryView":621 + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + * + * slice_copy(self, &mslice) # <<<<<<<<<<<<<< + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, + * self.view.itemsize, + */ + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice)); + + /* "View.MemoryView":622 + * + * slice_copy(self, &mslice) + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_C_CONTIGUOUS, + */ + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 622, __pyx_L1_error) + __pyx_v_mslice = __pyx_t_1; + + /* "View.MemoryView":627 + * self.dtype_is_object) + * + * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<< + * + * def copy_fortran(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 627, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":617 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":629 + * return memoryview_copy_from_slice(self, &mslice) + * + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("copy_fortran", 0); + + /* "View.MemoryView":631 + * def copy_fortran(self): + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<< + * + * slice_copy(self, &src) + */ + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS)); + + /* "View.MemoryView":633 + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + * + * slice_copy(self, &src) # <<<<<<<<<<<<<< + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, + * self.view.itemsize, + */ + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src)); + + /* "View.MemoryView":634 + * + * slice_copy(self, &src) + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_F_CONTIGUOUS, + */ + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 634, __pyx_L1_error) + __pyx_v_dst = __pyx_t_1; + + /* "View.MemoryView":639 + * self.dtype_is_object) + * + * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 639, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":629 + * return memoryview_copy_from_slice(self, &mslice) + * + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":643 + * + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + */ + +static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) { + struct __pyx_memoryview_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("memoryview_cwrapper", 0); + + /* "View.MemoryView":644 + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<< + * result.typeinfo = typeinfo + * return result + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_o); + __Pyx_GIVEREF(__pyx_v_o); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":645 + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_v_result->typeinfo = __pyx_v_typeinfo; + + /* "View.MemoryView":646 + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + * return result # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_check') + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":643 + * + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":649 + * + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) + * + */ + +static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("memoryview_check", 0); + + /* "View.MemoryView":650 + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): + * return isinstance(o, memoryview) # <<<<<<<<<<<<<< + * + * cdef tuple _unellipsify(object index, int ndim): + */ + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); + __pyx_r = __pyx_t_1; + goto __pyx_L0; + + /* "View.MemoryView":649 + * + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":652 + * return isinstance(o, memoryview) + * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with + */ + +static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { + PyObject *__pyx_v_tup = NULL; + PyObject *__pyx_v_result = NULL; + int __pyx_v_have_slices; + int __pyx_v_seen_ellipsis; + CYTHON_UNUSED PyObject *__pyx_v_idx = NULL; + PyObject *__pyx_v_item = NULL; + Py_ssize_t __pyx_v_nslices; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + __Pyx_RefNannySetupContext("_unellipsify", 0); + + /* "View.MemoryView":657 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: + */ + __pyx_t_1 = PyTuple_Check(__pyx_v_index); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":658 + * """ + * if not isinstance(index, tuple): + * tup = (index,) # <<<<<<<<<<<<<< + * else: + * tup = index + */ + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_index); + __Pyx_GIVEREF(__pyx_v_index); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index); + __pyx_v_tup = __pyx_t_3; + __pyx_t_3 = 0; + + /* "View.MemoryView":657 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":660 + * tup = (index,) + * else: + * tup = index # <<<<<<<<<<<<<< + * + * result = [] + */ + /*else*/ { + __Pyx_INCREF(__pyx_v_index); + __pyx_v_tup = __pyx_v_index; + } + __pyx_L3:; + + /* "View.MemoryView":662 + * tup = index + * + * result = [] # <<<<<<<<<<<<<< + * have_slices = False + * seen_ellipsis = False + */ + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 662, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_result = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":663 + * + * result = [] + * have_slices = False # <<<<<<<<<<<<<< + * seen_ellipsis = False + * for idx, item in enumerate(tup): + */ + __pyx_v_have_slices = 0; + + /* "View.MemoryView":664 + * result = [] + * have_slices = False + * seen_ellipsis = False # <<<<<<<<<<<<<< + * for idx, item in enumerate(tup): + * if item is Ellipsis: + */ + __pyx_v_seen_ellipsis = 0; + + /* "View.MemoryView":665 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_3 = __pyx_int_0; + if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) { + __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 665, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } + } else { + __pyx_t_7 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_7)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 665, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_7); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_INCREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3); + __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); + __pyx_t_3 = __pyx_t_7; + __pyx_t_7 = 0; + + /* "View.MemoryView":666 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + */ + __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":667 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True + */ + __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":668 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: + */ + __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) + __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__17); + __Pyx_GIVEREF(__pyx_slice__17); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__17); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "View.MemoryView":669 + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True # <<<<<<<<<<<<<< + * else: + * result.append(slice(None)) + */ + __pyx_v_seen_ellipsis = 1; + + /* "View.MemoryView":667 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True + */ + goto __pyx_L7; + } + + /* "View.MemoryView":671 + * seen_ellipsis = True + * else: + * result.append(slice(None)) # <<<<<<<<<<<<<< + * have_slices = True + * else: + */ + /*else*/ { + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__18); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) + } + __pyx_L7:; + + /* "View.MemoryView":672 + * else: + * result.append(slice(None)) + * have_slices = True # <<<<<<<<<<<<<< + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): + */ + __pyx_v_have_slices = 1; + + /* "View.MemoryView":666 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + */ + goto __pyx_L6; + } + + /* "View.MemoryView":674 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + */ + /*else*/ { + __pyx_t_2 = PySlice_Check(__pyx_v_item); + __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); + __pyx_t_1 = __pyx_t_10; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + /* "View.MemoryView":675 + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): + * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<< + * + * have_slices = have_slices or isinstance(item, slice) + */ + __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_Raise(__pyx_t_7, 0, 0, 0); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __PYX_ERR(2, 675, __pyx_L1_error) + + /* "View.MemoryView":674 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + */ + } + + /* "View.MemoryView":677 + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<< + * result.append(item) + * + */ + __pyx_t_10 = (__pyx_v_have_slices != 0); + if (!__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = PySlice_Check(__pyx_v_item); + __pyx_t_2 = (__pyx_t_10 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_have_slices = __pyx_t_1; + + /* "View.MemoryView":678 + * + * have_slices = have_slices or isinstance(item, slice) + * result.append(item) # <<<<<<<<<<<<<< + * + * nslices = ndim - len(result) + */ + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 678, __pyx_L1_error) + } + __pyx_L6:; + + /* "View.MemoryView":665 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: + */ + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":680 + * result.append(item) + * + * nslices = ndim - len(result) # <<<<<<<<<<<<<< + * if nslices: + * result.extend([slice(None)] * nslices) + */ + __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(2, 680, __pyx_L1_error) + __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5); + + /* "View.MemoryView":681 + * + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) + * + */ + __pyx_t_1 = (__pyx_v_nslices != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":682 + * nslices = ndim - len(result) + * if nslices: + * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + * + * return have_slices or nslices, tuple(result) + */ + __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__19); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":681 + * + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) + * + */ + } + + /* "View.MemoryView":684 + * result.extend([slice(None)] * nslices) + * + * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<< + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + */ + __Pyx_XDECREF(__pyx_r); + if (!__pyx_v_have_slices) { + } else { + __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_L14_bool_binop_done:; + __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = ((PyObject*)__pyx_t_7); + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "View.MemoryView":652 + * return isinstance(o, memoryview) + * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_tup); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_XDECREF(__pyx_v_item); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":686 + * return have_slices or nslices, tuple(result) + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + */ + +static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t *__pyx_t_1; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); + + /* "View.MemoryView":687 + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") + */ + __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); + for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { + __pyx_t_1 = __pyx_t_3; + __pyx_v_suboffset = (__pyx_t_1[0]); + + /* "View.MemoryView":688 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") + * + */ + __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":689 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 689, __pyx_L1_error) + + /* "View.MemoryView":688 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") + * + */ + } + } + + /* "View.MemoryView":686 + * return have_slices or nslices, tuple(result) + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":696 + * + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step + */ + +static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) { + int __pyx_v_new_ndim; + int __pyx_v_suboffset_dim; + int __pyx_v_dim; + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + __Pyx_memviewslice *__pyx_v_p_src; + struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0; + __Pyx_memviewslice *__pyx_v_p_dst; + int *__pyx_v_p_suboffset_dim; + Py_ssize_t __pyx_v_start; + Py_ssize_t __pyx_v_stop; + Py_ssize_t __pyx_v_step; + int __pyx_v_have_start; + int __pyx_v_have_stop; + int __pyx_v_have_step; + PyObject *__pyx_v_index = NULL; + struct __pyx_memoryview_obj *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + struct __pyx_memoryview_obj *__pyx_t_4; + char *__pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + Py_ssize_t __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + __Pyx_RefNannySetupContext("memview_slice", 0); + + /* "View.MemoryView":697 + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): + * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< + * cdef bint negative_step + * cdef __Pyx_memviewslice src, dst + */ + __pyx_v_new_ndim = 0; + __pyx_v_suboffset_dim = -1; + + /* "View.MemoryView":704 + * + * + * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< + * + * cdef _memoryviewslice memviewsliceobj + */ + memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))); + + /* "View.MemoryView":708 + * cdef _memoryviewslice memviewsliceobj + * + * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(2, 708, __pyx_L1_error) + } + } + #endif + + /* "View.MemoryView":710 + * assert memview.view.ndim > 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":711 + * + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview # <<<<<<<<<<<<<< + * p_src = &memviewsliceobj.from_slice + * else: + */ + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 711, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":712 + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, &src) + */ + __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice); + + /* "View.MemoryView":710 + * assert memview.view.ndim > 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice + */ + goto __pyx_L3; + } + + /* "View.MemoryView":714 + * p_src = &memviewsliceobj.from_slice + * else: + * slice_copy(memview, &src) # <<<<<<<<<<<<<< + * p_src = &src + * + */ + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); + + /* "View.MemoryView":715 + * else: + * slice_copy(memview, &src) + * p_src = &src # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_p_src = (&__pyx_v_src); + } + __pyx_L3:; + + /* "View.MemoryView":721 + * + * + * dst.memview = p_src.memview # <<<<<<<<<<<<<< + * dst.data = p_src.data + * + */ + __pyx_t_4 = __pyx_v_p_src->memview; + __pyx_v_dst.memview = __pyx_t_4; + + /* "View.MemoryView":722 + * + * dst.memview = p_src.memview + * dst.data = p_src.data # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __pyx_v_p_src->data; + __pyx_v_dst.data = __pyx_t_5; + + /* "View.MemoryView":727 + * + * + * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< + * cdef int *p_suboffset_dim = &suboffset_dim + * cdef Py_ssize_t start, stop, step + */ + __pyx_v_p_dst = (&__pyx_v_dst); + + /* "View.MemoryView":728 + * + * cdef __Pyx_memviewslice *p_dst = &dst + * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< + * cdef Py_ssize_t start, stop, step + * cdef bint have_start, have_stop, have_step + */ + __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); + + /* "View.MemoryView":732 + * cdef bint have_start, have_stop, have_step + * + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( + */ + __pyx_t_6 = 0; + if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) { + __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 732, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } else { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } + } else { + __pyx_t_9 = __pyx_t_8(__pyx_t_3); + if (unlikely(!__pyx_t_9)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 732, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_v_dim = __pyx_t_6; + __pyx_t_6 = (__pyx_t_6 + 1); + + /* "View.MemoryView":733 + * + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + */ + __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":737 + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< + * 0, 0, 0, # have_{start,stop,step} + * False) + */ + __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 737, __pyx_L1_error) + + /* "View.MemoryView":734 + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + */ + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 734, __pyx_L1_error) + + /* "View.MemoryView":733 + * + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + */ + goto __pyx_L6; + } + + /* "View.MemoryView":740 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + */ + __pyx_t_2 = (__pyx_v_index == Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":741 + * False) + * elif index is None: + * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 + */ + (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; + + /* "View.MemoryView":742 + * elif index is None: + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 + */ + (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; + + /* "View.MemoryView":743 + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< + * new_ndim += 1 + * else: + */ + (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; + + /* "View.MemoryView":744 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 # <<<<<<<<<<<<<< + * else: + * start = index.start or 0 + */ + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); + + /* "View.MemoryView":740 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + */ + goto __pyx_L6; + } + + /* "View.MemoryView":746 + * new_ndim += 1 + * else: + * start = index.start or 0 # <<<<<<<<<<<<<< + * stop = index.stop or 0 + * step = index.step or 0 + */ + /*else*/ { + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 746, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 746, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 746, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L7_bool_binop_done:; + __pyx_v_start = __pyx_t_10; + + /* "View.MemoryView":747 + * else: + * start = index.start or 0 + * stop = index.stop or 0 # <<<<<<<<<<<<<< + * step = index.step or 0 + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 747, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 747, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 747, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L9_bool_binop_done:; + __pyx_v_stop = __pyx_t_10; + + /* "View.MemoryView":748 + * start = index.start or 0 + * stop = index.stop or 0 + * step = index.step or 0 # <<<<<<<<<<<<<< + * + * have_start = index.start is not None + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 748, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 748, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 748, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L11_bool_binop_done:; + __pyx_v_step = __pyx_t_10; + + /* "View.MemoryView":750 + * step = index.step or 0 + * + * have_start = index.start is not None # <<<<<<<<<<<<<< + * have_stop = index.stop is not None + * have_step = index.step is not None + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 750, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_start = __pyx_t_1; + + /* "View.MemoryView":751 + * + * have_start = index.start is not None + * have_stop = index.stop is not None # <<<<<<<<<<<<<< + * have_step = index.step is not None + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 751, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_stop = __pyx_t_1; + + /* "View.MemoryView":752 + * have_start = index.start is not None + * have_stop = index.stop is not None + * have_step = index.step is not None # <<<<<<<<<<<<<< + * + * slice_memviewslice( + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 752, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_step = __pyx_t_1; + + /* "View.MemoryView":754 + * have_step = index.step is not None + * + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + */ + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 754, __pyx_L1_error) + + /* "View.MemoryView":760 + * have_start, have_stop, have_step, + * True) + * new_ndim += 1 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): + */ + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); + } + __pyx_L6:; + + /* "View.MemoryView":732 + * cdef bint have_start, have_stop, have_step + * + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( + */ + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":762 + * new_ndim += 1 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":763 + * + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + + /* "View.MemoryView":764 + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< + * memviewsliceobj.to_dtype_func, + * memview.dtype_is_object) + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 764, __pyx_L1_error) } + + /* "View.MemoryView":765 + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * else: + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 765, __pyx_L1_error) } + + /* "View.MemoryView":763 + * + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, + */ + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 763, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 763, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":762 + * new_ndim += 1 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + } + + /* "View.MemoryView":768 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * + */ + /*else*/ { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + + /* "View.MemoryView":769 + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, + * memview.dtype_is_object) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 768, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + + /* "View.MemoryView":768 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * + */ + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 768, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":696 + * + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":793 + * + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + */ + +static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) { + Py_ssize_t __pyx_v_new_shape; + int __pyx_v_negative_step; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + + /* "View.MemoryView":813 + * cdef bint negative_step + * + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: + */ + __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":815 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: + */ + __pyx_t_1 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":816 + * + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + */ + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); + + /* "View.MemoryView":815 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: + */ + } + + /* "View.MemoryView":817 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + * else: + */ + __pyx_t_1 = (0 <= __pyx_v_start); + if (__pyx_t_1) { + __pyx_t_1 = (__pyx_v_start < __pyx_v_shape); + } + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":818 + * start += shape + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< + * else: + * + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 818, __pyx_L1_error) + + /* "View.MemoryView":817 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + * else: + */ + } + + /* "View.MemoryView":813 + * cdef bint negative_step + * + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":821 + * else: + * + * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< + * + * if have_step and step == 0: + */ + /*else*/ { + __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step < 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L6_bool_binop_done:; + __pyx_v_negative_step = __pyx_t_2; + + /* "View.MemoryView":823 + * negative_step = have_step != 0 and step < 0 + * + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * + */ + __pyx_t_1 = (__pyx_v_have_step != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step == 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L9_bool_binop_done:; + if (__pyx_t_2) { + + /* "View.MemoryView":824 + * + * if have_step and step == 0: + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 824, __pyx_L1_error) + + /* "View.MemoryView":823 + * negative_step = have_step != 0 and step < 0 + * + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * + */ + } + + /* "View.MemoryView":827 + * + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape + */ + __pyx_t_2 = (__pyx_v_have_start != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":828 + * + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: + */ + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":829 + * if have_start: + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if start < 0: + * start = 0 + */ + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); + + /* "View.MemoryView":830 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: + */ + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":831 + * start += shape + * if start < 0: + * start = 0 # <<<<<<<<<<<<<< + * elif start >= shape: + * if negative_step: + */ + __pyx_v_start = 0; + + /* "View.MemoryView":830 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: + */ + } + + /* "View.MemoryView":828 + * + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: + */ + goto __pyx_L12; + } + + /* "View.MemoryView":832 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 + */ + __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":833 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":834 + * elif start >= shape: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = shape + */ + __pyx_v_start = (__pyx_v_shape - 1); + + /* "View.MemoryView":833 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + goto __pyx_L14; + } + + /* "View.MemoryView":836 + * start = shape - 1 + * else: + * start = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: + */ + /*else*/ { + __pyx_v_start = __pyx_v_shape; + } + __pyx_L14:; + + /* "View.MemoryView":832 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 + */ + } + __pyx_L12:; + + /* "View.MemoryView":827 + * + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape + */ + goto __pyx_L11; + } + + /* "View.MemoryView":838 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":839 + * else: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = 0 + */ + __pyx_v_start = (__pyx_v_shape - 1); + + /* "View.MemoryView":838 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + goto __pyx_L15; + } + + /* "View.MemoryView":841 + * start = shape - 1 + * else: + * start = 0 # <<<<<<<<<<<<<< + * + * if have_stop: + */ + /*else*/ { + __pyx_v_start = 0; + } + __pyx_L15:; + } + __pyx_L11:; + + /* "View.MemoryView":843 + * start = 0 + * + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape + */ + __pyx_t_2 = (__pyx_v_have_stop != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":844 + * + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: + */ + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":845 + * if have_stop: + * if stop < 0: + * stop += shape # <<<<<<<<<<<<<< + * if stop < 0: + * stop = 0 + */ + __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); + + /* "View.MemoryView":846 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: + */ + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":847 + * stop += shape + * if stop < 0: + * stop = 0 # <<<<<<<<<<<<<< + * elif stop > shape: + * stop = shape + */ + __pyx_v_stop = 0; + + /* "View.MemoryView":846 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: + */ + } + + /* "View.MemoryView":844 + * + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: + */ + goto __pyx_L17; + } + + /* "View.MemoryView":848 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: + */ + __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":849 + * stop = 0 + * elif stop > shape: + * stop = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: + */ + __pyx_v_stop = __pyx_v_shape; + + /* "View.MemoryView":848 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: + */ + } + __pyx_L17:; + + /* "View.MemoryView":843 + * start = 0 + * + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape + */ + goto __pyx_L16; + } + + /* "View.MemoryView":851 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: + */ + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":852 + * else: + * if negative_step: + * stop = -1 # <<<<<<<<<<<<<< + * else: + * stop = shape + */ + __pyx_v_stop = -1L; + + /* "View.MemoryView":851 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: + */ + goto __pyx_L19; + } + + /* "View.MemoryView":854 + * stop = -1 + * else: + * stop = shape # <<<<<<<<<<<<<< + * + * if not have_step: + */ + /*else*/ { + __pyx_v_stop = __pyx_v_shape; + } + __pyx_L19:; + } + __pyx_L16:; + + /* "View.MemoryView":856 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 + * + */ + __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":857 + * + * if not have_step: + * step = 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_step = 1; + + /* "View.MemoryView":856 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 + * + */ + } + + /* "View.MemoryView":861 + * + * with cython.cdivision(True): + * new_shape = (stop - start) // step # <<<<<<<<<<<<<< + * + * if (stop - start) - step * new_shape: + */ + __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); + + /* "View.MemoryView":863 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 + * + */ + __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":864 + * + * if (stop - start) - step * new_shape: + * new_shape += 1 # <<<<<<<<<<<<<< + * + * if new_shape < 0: + */ + __pyx_v_new_shape = (__pyx_v_new_shape + 1); + + /* "View.MemoryView":863 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 + * + */ + } + + /* "View.MemoryView":866 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 + * + */ + __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":867 + * + * if new_shape < 0: + * new_shape = 0 # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_new_shape = 0; + + /* "View.MemoryView":866 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 + * + */ + } + + /* "View.MemoryView":870 + * + * + * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset + */ + (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); + + /* "View.MemoryView":871 + * + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< + * dst.suboffsets[new_ndim] = suboffset + * + */ + (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; + + /* "View.MemoryView":872 + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset; + } + __pyx_L3:; + + /* "View.MemoryView":875 + * + * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: + */ + __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":876 + * + * if suboffset_dim[0] < 0: + * dst.data += start * stride # <<<<<<<<<<<<<< + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride + */ + __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride)); + + /* "View.MemoryView":875 + * + * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: + */ + goto __pyx_L23; + } + + /* "View.MemoryView":878 + * dst.data += start * stride + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< + * + * if suboffset >= 0: + */ + /*else*/ { + __pyx_t_3 = (__pyx_v_suboffset_dim[0]); + (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride)); + } + __pyx_L23:; + + /* "View.MemoryView":880 + * dst.suboffsets[suboffset_dim[0]] += start * stride + * + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: + */ + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":881 + * + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset + */ + __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":882 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: + */ + __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":883 + * if not is_slice: + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " + */ + __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset); + + /* "View.MemoryView":882 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: + */ + goto __pyx_L26; + } + + /* "View.MemoryView":885 + * dst.data = ( dst.data)[0] + suboffset + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< + * "must be indexed and not sliced", dim) + * else: + */ + /*else*/ { + + /* "View.MemoryView":886 + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " + * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<< + * else: + * suboffset_dim[0] = new_ndim + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 885, __pyx_L1_error) + } + __pyx_L26:; + + /* "View.MemoryView":881 + * + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset + */ + goto __pyx_L25; + } + + /* "View.MemoryView":888 + * "must be indexed and not sliced", dim) + * else: + * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< + * + * return 0 + */ + /*else*/ { + (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim; + } + __pyx_L25:; + + /* "View.MemoryView":880 + * dst.suboffsets[suboffset_dim[0]] += start * stride + * + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: + */ + } + + /* "View.MemoryView":890 + * suboffset_dim[0] = new_ndim + * + * return 0 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":793 + * + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":896 + * + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + */ + +static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) { + Py_ssize_t __pyx_v_shape; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_suboffset; + Py_ssize_t __pyx_v_itemsize; + char *__pyx_v_resultp; + char *__pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("pybuffer_index", 0); + + /* "View.MemoryView":898 + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< + * cdef Py_ssize_t itemsize = view.itemsize + * cdef char *resultp + */ + __pyx_v_suboffset = -1L; + + /* "View.MemoryView":899 + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< + * cdef char *resultp + * + */ + __pyx_t_1 = __pyx_v_view->itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":902 + * cdef char *resultp + * + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize + */ + __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":903 + * + * if view.ndim == 0: + * shape = view.len / itemsize # <<<<<<<<<<<<<< + * stride = itemsize + * else: + */ + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(2, 903, __pyx_L1_error) + } + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(2, 903, __pyx_L1_error) + } + __pyx_v_shape = (__pyx_v_view->len / __pyx_v_itemsize); + + /* "View.MemoryView":904 + * if view.ndim == 0: + * shape = view.len / itemsize + * stride = itemsize # <<<<<<<<<<<<<< + * else: + * shape = view.shape[dim] + */ + __pyx_v_stride = __pyx_v_itemsize; + + /* "View.MemoryView":902 + * cdef char *resultp + * + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize + */ + goto __pyx_L3; + } + + /* "View.MemoryView":906 + * stride = itemsize + * else: + * shape = view.shape[dim] # <<<<<<<<<<<<<< + * stride = view.strides[dim] + * if view.suboffsets != NULL: + */ + /*else*/ { + __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); + + /* "View.MemoryView":907 + * else: + * shape = view.shape[dim] + * stride = view.strides[dim] # <<<<<<<<<<<<<< + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] + */ + __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); + + /* "View.MemoryView":908 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] + * + */ + __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":909 + * stride = view.strides[dim] + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< + * + * if index < 0: + */ + __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]); + + /* "View.MemoryView":908 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] + * + */ + } + } + __pyx_L3:; + + /* "View.MemoryView":911 + * suboffset = view.suboffsets[dim] + * + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: + */ + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":912 + * + * if index < 0: + * index += view.shape[dim] # <<<<<<<<<<<<<< + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + */ + __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); + + /* "View.MemoryView":913 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":914 + * index += view.shape[dim] + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< + * + * if index >= shape: + */ + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(2, 914, __pyx_L1_error) + + /* "View.MemoryView":913 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + } + + /* "View.MemoryView":911 + * suboffset = view.suboffsets[dim] + * + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: + */ + } + + /* "View.MemoryView":916 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":917 + * + * if index >= shape: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< + * + * resultp = bufp + index * stride + */ + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 917, __pyx_L1_error) + + /* "View.MemoryView":916 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + } + + /* "View.MemoryView":919 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * resultp = bufp + index * stride # <<<<<<<<<<<<<< + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset + */ + __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); + + /* "View.MemoryView":920 + * + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset + * + */ + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":921 + * resultp = bufp + index * stride + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< + * + * return resultp + */ + __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset); + + /* "View.MemoryView":920 + * + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset + * + */ + } + + /* "View.MemoryView":923 + * resultp = ( resultp)[0] + suboffset + * + * return resultp # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_resultp; + goto __pyx_L0; + + /* "View.MemoryView":896 + * + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":929 + * + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim + * + */ + +static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { + int __pyx_v_ndim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_r; + int __pyx_t_1; + Py_ssize_t *__pyx_t_2; + long __pyx_t_3; + Py_ssize_t __pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + + /* "View.MemoryView":930 + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: + * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< + * + * cdef Py_ssize_t *shape = memslice.shape + */ + __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; + __pyx_v_ndim = __pyx_t_1; + + /* "View.MemoryView":932 + * cdef int ndim = memslice.memview.view.ndim + * + * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< + * cdef Py_ssize_t *strides = memslice.strides + * + */ + __pyx_t_2 = __pyx_v_memslice->shape; + __pyx_v_shape = __pyx_t_2; + + /* "View.MemoryView":933 + * + * cdef Py_ssize_t *shape = memslice.shape + * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __pyx_v_memslice->strides; + __pyx_v_strides = __pyx_t_2; + + /* "View.MemoryView":937 + * + * cdef int i, j + * for i in range(ndim / 2): # <<<<<<<<<<<<<< + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] + */ + __pyx_t_3 = (__pyx_v_ndim / 2); + for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":938 + * cdef int i, j + * for i in range(ndim / 2): + * j = ndim - 1 - i # <<<<<<<<<<<<<< + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] + */ + __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); + + /* "View.MemoryView":939 + * for i in range(ndim / 2): + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< + * shape[i], shape[j] = shape[j], shape[i] + * + */ + __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]); + __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]); + (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4; + (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5; + + /* "View.MemoryView":940 + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + */ + __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]); + __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]); + (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5; + (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4; + + /* "View.MemoryView":942 + * shape[i], shape[j] = shape[j], shape[i] + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + */ + __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L6_bool_binop_done:; + if (__pyx_t_6) { + + /* "View.MemoryView":943 + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< + * + * return 1 + */ + __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 943, __pyx_L1_error) + + /* "View.MemoryView":942 + * shape[i], shape[j] = shape[j], shape[i] + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + */ + } + } + + /* "View.MemoryView":945 + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + * return 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 1; + goto __pyx_L0; + + /* "View.MemoryView":929 + * + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim + * + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = 0; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":962 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + */ + +/* Python wrapper */ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":963 + * + * def __dealloc__(self): + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< + * + * cdef convert_item_to_object(self, char *itemp): + */ + __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); + + /* "View.MemoryView":962 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":965 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) + */ + +static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("convert_item_to_object", 0); + + /* "View.MemoryView":966 + * + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: + */ + __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":967 + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) # <<<<<<<<<<<<<< + * else: + * return memoryview.convert_item_to_object(self, itemp) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 967, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":966 + * + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: + */ + } + + /* "View.MemoryView":969 + * return self.to_object_func(itemp) + * else: + * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< + * + * cdef assign_item_from_object(self, char *itemp, object value): + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 969, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":965 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":971 + * return memoryview.convert_item_to_object(self, itemp) + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) + */ + +static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("assign_item_from_object", 0); + + /* "View.MemoryView":972 + * + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: + */ + __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":973 + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< + * else: + * memoryview.assign_item_from_object(self, itemp, value) + */ + __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 973, __pyx_L1_error) + + /* "View.MemoryView":972 + * + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":975 + * self.to_dtype_func(itemp, value) + * else: + * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< + * + * @property + */ + /*else*/ { + __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 975, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":971 + * return memoryview.convert_item_to_object(self, itemp) + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":978 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":979 + * @property + * def base(self): + * return self.from_object # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->from_object); + __pyx_r = __pyx_v_self->from_object; + goto __pyx_L0; + + /* "View.MemoryView":978 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":985 + * + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), + */ + +static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TypeInfo *__pyx_t_4; + Py_buffer __pyx_t_5; + Py_ssize_t *__pyx_t_6; + Py_ssize_t *__pyx_t_7; + Py_ssize_t *__pyx_t_8; + Py_ssize_t __pyx_t_9; + __Pyx_RefNannySetupContext("memoryview_fromslice", 0); + + /* "View.MemoryView":993 + * cdef _memoryviewslice result + * + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":994 + * + * if memviewslice.memview == Py_None: + * return None # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + + /* "View.MemoryView":993 + * cdef _memoryviewslice result + * + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None + * + */ + } + + /* "View.MemoryView":999 + * + * + * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< + * + * result.from_slice = memviewslice + */ + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":1001 + * result = _memoryviewslice(None, 0, dtype_is_object) + * + * result.from_slice = memviewslice # <<<<<<<<<<<<<< + * __PYX_INC_MEMVIEW(&memviewslice, 1) + * + */ + __pyx_v_result->from_slice = __pyx_v_memviewslice; + + /* "View.MemoryView":1002 + * + * result.from_slice = memviewslice + * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< + * + * result.from_object = ( memviewslice.memview).base + */ + __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); + + /* "View.MemoryView":1004 + * __PYX_INC_MEMVIEW(&memviewslice, 1) + * + * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< + * result.typeinfo = memviewslice.memview.typeinfo + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1004, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_result->from_object); + __Pyx_DECREF(__pyx_v_result->from_object); + __pyx_v_result->from_object = __pyx_t_2; + __pyx_t_2 = 0; + + /* "View.MemoryView":1005 + * + * result.from_object = ( memviewslice.memview).base + * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< + * + * result.view = memviewslice.memview.view + */ + __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; + __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; + + /* "View.MemoryView":1007 + * result.typeinfo = memviewslice.memview.typeinfo + * + * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< + * result.view.buf = memviewslice.data + * result.view.ndim = ndim + */ + __pyx_t_5 = __pyx_v_memviewslice.memview->view; + __pyx_v_result->__pyx_base.view = __pyx_t_5; + + /* "View.MemoryView":1008 + * + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None + */ + __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); + + /* "View.MemoryView":1009 + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data + * result.view.ndim = ndim # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) + */ + __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; + + /* "View.MemoryView":1010 + * result.view.buf = memviewslice.data + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; + + /* "View.MemoryView":1011 + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * result.flags = PyBUF_RECORDS + */ + Py_INCREF(Py_None); + + /* "View.MemoryView":1013 + * Py_INCREF(Py_None) + * + * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< + * + * result.view.shape = result.from_slice.shape + */ + __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; + + /* "View.MemoryView":1015 + * result.flags = PyBUF_RECORDS + * + * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< + * result.view.strides = result.from_slice.strides + * + */ + __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); + + /* "View.MemoryView":1016 + * + * result.view.shape = result.from_slice.shape + * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); + + /* "View.MemoryView":1019 + * + * + * result.view.suboffsets = NULL # <<<<<<<<<<<<<< + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: + */ + __pyx_v_result->__pyx_base.view.suboffsets = NULL; + + /* "View.MemoryView":1020 + * + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets + */ + __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_v_suboffset = (__pyx_t_6[0]); + + /* "View.MemoryView":1021 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break + */ + __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1022 + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); + + /* "View.MemoryView":1023 + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets + * break # <<<<<<<<<<<<<< + * + * result.view.len = result.view.itemsize + */ + goto __pyx_L5_break; + + /* "View.MemoryView":1021 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break + */ + } + } + __pyx_L5_break:; + + /* "View.MemoryView":1025 + * break + * + * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< + * for length in result.view.shape[:ndim]: + * result.view.len *= length + */ + __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + + /* "View.MemoryView":1026 + * + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< + * result.view.len *= length + * + */ + __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1026, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":1027 + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: + * result.view.len *= length # <<<<<<<<<<<<<< + * + * result.to_object_func = to_object_func + */ + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + } + + /* "View.MemoryView":1029 + * result.view.len *= length + * + * result.to_object_func = to_object_func # <<<<<<<<<<<<<< + * result.to_dtype_func = to_dtype_func + * + */ + __pyx_v_result->to_object_func = __pyx_v_to_object_func; + + /* "View.MemoryView":1030 + * + * result.to_object_func = to_object_func + * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< + * + * return result + */ + __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; + + /* "View.MemoryView":1032 + * result.to_dtype_func = to_dtype_func + * + * return result # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":985 + * + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1035 + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + */ + +static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) { + struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0; + __Pyx_memviewslice *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_slice_from_memview", 0); + + /* "View.MemoryView":1038 + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1039 + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): + * obj = memview # <<<<<<<<<<<<<< + * return &obj.from_slice + * else: + */ + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 1039, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":1040 + * if isinstance(memview, _memoryviewslice): + * obj = memview + * return &obj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, mslice) + */ + __pyx_r = (&__pyx_v_obj->from_slice); + goto __pyx_L0; + + /* "View.MemoryView":1038 + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice + */ + } + + /* "View.MemoryView":1042 + * return &obj.from_slice + * else: + * slice_copy(memview, mslice) # <<<<<<<<<<<<<< + * return mslice + * + */ + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); + + /* "View.MemoryView":1043 + * else: + * slice_copy(memview, mslice) + * return mslice # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_slice_copy') + */ + __pyx_r = __pyx_v_mslice; + goto __pyx_L0; + } + + /* "View.MemoryView":1035 + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_obj); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1046 + * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets + */ + +static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) { + int __pyx_v_dim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + Py_ssize_t *__pyx_v_suboffsets; + __Pyx_RefNannyDeclarations + Py_ssize_t *__pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + __Pyx_RefNannySetupContext("slice_copy", 0); + + /* "View.MemoryView":1050 + * cdef (Py_ssize_t*) shape, strides, suboffsets + * + * shape = memview.view.shape # <<<<<<<<<<<<<< + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets + */ + __pyx_t_1 = __pyx_v_memview->view.shape; + __pyx_v_shape = __pyx_t_1; + + /* "View.MemoryView":1051 + * + * shape = memview.view.shape + * strides = memview.view.strides # <<<<<<<<<<<<<< + * suboffsets = memview.view.suboffsets + * + */ + __pyx_t_1 = __pyx_v_memview->view.strides; + __pyx_v_strides = __pyx_t_1; + + /* "View.MemoryView":1052 + * shape = memview.view.shape + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< + * + * dst.memview = <__pyx_memoryview *> memview + */ + __pyx_t_1 = __pyx_v_memview->view.suboffsets; + __pyx_v_suboffsets = __pyx_t_1; + + /* "View.MemoryView":1054 + * suboffsets = memview.view.suboffsets + * + * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< + * dst.data = memview.view.buf + * + */ + __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); + + /* "View.MemoryView":1055 + * + * dst.memview = <__pyx_memoryview *> memview + * dst.data = memview.view.buf # <<<<<<<<<<<<<< + * + * for dim in range(memview.view.ndim): + */ + __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); + + /* "View.MemoryView":1057 + * dst.data = memview.view.buf + * + * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] + */ + __pyx_t_2 = __pyx_v_memview->view.ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_dim = __pyx_t_3; + + /* "View.MemoryView":1058 + * + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + */ + (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); + + /* "View.MemoryView":1059 + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + * + */ + (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); + + /* "View.MemoryView":1060 + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_object') + */ + if ((__pyx_v_suboffsets != 0)) { + __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]); + } else { + __pyx_t_4 = -1L; + } + (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4; + } + + /* "View.MemoryView":1046 + * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + */ + +static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) { + __Pyx_memviewslice __pyx_v_memviewslice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("memoryview_copy", 0); + + /* "View.MemoryView":1066 + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< + * return memoryview_copy_from_slice(memview, &memviewslice) + * + */ + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); + + /* "View.MemoryView":1067 + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) + * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_object_from_slice') + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1067, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1070 + * + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. + */ + +static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) { + PyObject *(*__pyx_v_to_object_func)(char *); + int (*__pyx_v_to_dtype_func)(char *, PyObject *); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *(*__pyx_t_3)(char *); + int (*__pyx_t_4)(char *, PyObject *); + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); + + /* "View.MemoryView":1077 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1078 + * + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: + */ + __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; + __pyx_v_to_object_func = __pyx_t_3; + + /* "View.MemoryView":1079 + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< + * else: + * to_object_func = NULL + */ + __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func; + __pyx_v_to_dtype_func = __pyx_t_4; + + /* "View.MemoryView":1077 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1081 + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: + * to_object_func = NULL # <<<<<<<<<<<<<< + * to_dtype_func = NULL + * + */ + /*else*/ { + __pyx_v_to_object_func = NULL; + + /* "View.MemoryView":1082 + * else: + * to_object_func = NULL + * to_dtype_func = NULL # <<<<<<<<<<<<<< + * + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + */ + __pyx_v_to_dtype_func = NULL; + } + __pyx_L3:; + + /* "View.MemoryView":1084 + * to_dtype_func = NULL + * + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< + * to_object_func, to_dtype_func, + * memview.dtype_is_object) + */ + __Pyx_XDECREF(__pyx_r); + + /* "View.MemoryView":1086 + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + * to_object_func, to_dtype_func, + * memview.dtype_is_object) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1084, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "View.MemoryView":1070 + * + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1092 + * + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg + */ + +static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { + Py_ssize_t __pyx_r; + int __pyx_t_1; + + /* "View.MemoryView":1093 + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: + */ + __pyx_t_1 = ((__pyx_v_arg < 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1094 + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: + * return -arg # <<<<<<<<<<<<<< + * else: + * return arg + */ + __pyx_r = (-__pyx_v_arg); + goto __pyx_L0; + + /* "View.MemoryView":1093 + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: + */ + } + + /* "View.MemoryView":1096 + * return -arg + * else: + * return arg # <<<<<<<<<<<<<< + * + * @cname('__pyx_get_best_slice_order') + */ + /*else*/ { + __pyx_r = __pyx_v_arg; + goto __pyx_L0; + } + + /* "View.MemoryView":1092 + * + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1099 + * + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. + */ + +static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) { + int __pyx_v_i; + Py_ssize_t __pyx_v_c_stride; + Py_ssize_t __pyx_v_f_stride; + char __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + + /* "View.MemoryView":1104 + * """ + * cdef int i + * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< + * cdef Py_ssize_t f_stride = 0 + * + */ + __pyx_v_c_stride = 0; + + /* "View.MemoryView":1105 + * cdef int i + * cdef Py_ssize_t c_stride = 0 + * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< + * + * for i in range(ndim - 1, -1, -1): + */ + __pyx_v_f_stride = 0; + + /* "View.MemoryView":1107 + * cdef Py_ssize_t f_stride = 0 + * + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] + */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":1108 + * + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break + */ + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1109 + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1110 + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + goto __pyx_L4_break; + + /* "View.MemoryView":1108 + * + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break + */ + } + } + __pyx_L4_break:; + + /* "View.MemoryView":1112 + * break + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] + */ + __pyx_t_1 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1113 + * + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break + */ + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1114 + * for i in range(ndim): + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1115 + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + */ + goto __pyx_L7_break; + + /* "View.MemoryView":1113 + * + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break + */ + } + } + __pyx_L7_break:; + + /* "View.MemoryView":1117 + * break + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: + */ + __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1118 + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + * return 'C' # <<<<<<<<<<<<<< + * else: + * return 'F' + */ + __pyx_r = 'C'; + goto __pyx_L0; + + /* "View.MemoryView":1117 + * break + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: + */ + } + + /* "View.MemoryView":1120 + * return 'C' + * else: + * return 'F' # <<<<<<<<<<<<<< + * + * @cython.cdivision(True) + */ + /*else*/ { + __pyx_r = 'F'; + goto __pyx_L0; + } + + /* "View.MemoryView":1099 + * + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1123 + * + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + */ + +static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent; + Py_ssize_t __pyx_v_dst_extent; + Py_ssize_t __pyx_v_src_stride; + Py_ssize_t __pyx_v_dst_stride; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + Py_ssize_t __pyx_t_5; + + /* "View.MemoryView":1130 + * + * cdef Py_ssize_t i + * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] + */ + __pyx_v_src_extent = (__pyx_v_src_shape[0]); + + /* "View.MemoryView":1131 + * cdef Py_ssize_t i + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] + */ + __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); + + /* "View.MemoryView":1132 + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + */ + __pyx_v_src_stride = (__pyx_v_src_strides[0]); + + /* "View.MemoryView":1133 + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< + * + * if ndim == 1: + */ + __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); + + /* "View.MemoryView":1135 + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + */ + __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1136 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + + /* "View.MemoryView":1137 + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: + */ + __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize); + if (__pyx_t_2) { + __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride)); + } + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L5_bool_binop_done:; + + /* "View.MemoryView":1136 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + if (__pyx_t_1) { + + /* "View.MemoryView":1138 + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): + */ + memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)); + + /* "View.MemoryView":1136 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + goto __pyx_L4; + } + + /* "View.MemoryView":1140 + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride + */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":1141 + * else: + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< + * src_data += src_stride + * dst_data += dst_stride + */ + memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize); + + /* "View.MemoryView":1142 + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * else: + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + + /* "View.MemoryView":1143 + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } + } + __pyx_L4:; + + /* "View.MemoryView":1135 + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1145 + * dst_data += dst_stride + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * _copy_strided_to_strided(src_data, src_strides + 1, + * dst_data, dst_strides + 1, + */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":1146 + * else: + * for i in range(dst_extent): + * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< + * dst_data, dst_strides + 1, + * src_shape + 1, dst_shape + 1, + */ + _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); + + /* "View.MemoryView":1150 + * src_shape + 1, dst_shape + 1, + * ndim - 1, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + + /* "View.MemoryView":1151 + * ndim - 1, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } + } + __pyx_L3:; + + /* "View.MemoryView":1123 + * + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + */ + + /* function exit code */ +} + +/* "View.MemoryView":1153 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ + +static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { + + /* "View.MemoryView":1156 + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< + * src.shape, dst.shape, ndim, itemsize) + * + */ + _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); + + /* "View.MemoryView":1153 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1160 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + */ + +static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) { + int __pyx_v_i; + Py_ssize_t __pyx_v_size; + Py_ssize_t __pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + + /* "View.MemoryView":1163 + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + * cdef Py_ssize_t size = src.memview.view.itemsize # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_size = __pyx_t_1; + + /* "View.MemoryView":1165 + * cdef Py_ssize_t size = src.memview.view.itemsize + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * size *= src.shape[i] + * + */ + __pyx_t_2 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1166 + * + * for i in range(ndim): + * size *= src.shape[i] # <<<<<<<<<<<<<< + * + * return size + */ + __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i])); + } + + /* "View.MemoryView":1168 + * size *= src.shape[i] + * + * return size # <<<<<<<<<<<<<< + * + * @cname('__pyx_fill_contig_strides_array') + */ + __pyx_r = __pyx_v_size; + goto __pyx_L0; + + /* "View.MemoryView":1160 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1171 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ + +static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) { + int __pyx_v_idx; + Py_ssize_t __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + + /* "View.MemoryView":1180 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + __pyx_t_1 = ((__pyx_v_order == 'F') != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1181 + * + * if order == 'F': + * for idx in range(ndim): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride = stride * shape[idx] + */ + __pyx_t_2 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_idx = __pyx_t_3; + + /* "View.MemoryView":1182 + * if order == 'F': + * for idx in range(ndim): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride = stride * shape[idx] + * else: + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; + + /* "View.MemoryView":1183 + * for idx in range(ndim): + * strides[idx] = stride + * stride = stride * shape[idx] # <<<<<<<<<<<<<< + * else: + * for idx in range(ndim - 1, -1, -1): + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } + + /* "View.MemoryView":1180 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1185 + * stride = stride * shape[idx] + * else: + * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride = stride * shape[idx] + */ + /*else*/ { + for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) { + __pyx_v_idx = __pyx_t_2; + + /* "View.MemoryView":1186 + * else: + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride = stride * shape[idx] + * + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; + + /* "View.MemoryView":1187 + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride + * stride = stride * shape[idx] # <<<<<<<<<<<<<< + * + * return stride + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } + } + __pyx_L3:; + + /* "View.MemoryView":1189 + * stride = stride * shape[idx] + * + * return stride # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_data_to_temp') + */ + __pyx_r = __pyx_v_stride; + goto __pyx_L0; + + /* "View.MemoryView":1171 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1192 + * + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, + */ + +static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) { + int __pyx_v_i; + void *__pyx_v_result; + size_t __pyx_v_itemsize; + size_t __pyx_v_size; + void *__pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + struct __pyx_memoryview_obj *__pyx_t_4; + int __pyx_t_5; + + /* "View.MemoryView":1203 + * cdef void *result + * + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef size_t size = slice_get_size(src, ndim) + * + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":1204 + * + * cdef size_t itemsize = src.memview.view.itemsize + * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< + * + * result = malloc(size) + */ + __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); + + /* "View.MemoryView":1206 + * cdef size_t size = slice_get_size(src, ndim) + * + * result = malloc(size) # <<<<<<<<<<<<<< + * if not result: + * _err(MemoryError, NULL) + */ + __pyx_v_result = malloc(__pyx_v_size); + + /* "View.MemoryView":1207 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ + __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1208 + * result = malloc(size) + * if not result: + * _err(MemoryError, NULL) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 1208, __pyx_L1_error) + + /* "View.MemoryView":1207 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ + } + + /* "View.MemoryView":1211 + * + * + * tmpslice.data = result # <<<<<<<<<<<<<< + * tmpslice.memview = src.memview + * for i in range(ndim): + */ + __pyx_v_tmpslice->data = ((char *)__pyx_v_result); + + /* "View.MemoryView":1212 + * + * tmpslice.data = result + * tmpslice.memview = src.memview # <<<<<<<<<<<<<< + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + */ + __pyx_t_4 = __pyx_v_src->memview; + __pyx_v_tmpslice->memview = __pyx_t_4; + + /* "View.MemoryView":1213 + * tmpslice.data = result + * tmpslice.memview = src.memview + * for i in range(ndim): # <<<<<<<<<<<<<< + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 + */ + __pyx_t_3 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":1214 + * tmpslice.memview = src.memview + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< + * tmpslice.suboffsets[i] = -1 + * + */ + (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); + + /* "View.MemoryView":1215 + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, + */ + (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; + } + + /* "View.MemoryView":1217 + * tmpslice.suboffsets[i] = -1 + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< + * ndim, order) + * + */ + __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order); + + /* "View.MemoryView":1221 + * + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 + */ + __pyx_t_3 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":1222 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 + * + */ + __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1223 + * for i in range(ndim): + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< + * + * if slice_is_contig(src[0], order, ndim): + */ + (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0; + + /* "View.MemoryView":1222 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 + * + */ + } + } + + /* "View.MemoryView":1225 + * tmpslice.strides[i] = 0 + * + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1226 + * + * if slice_is_contig(src[0], order, ndim): + * memcpy(result, src.data, size) # <<<<<<<<<<<<<< + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) + */ + memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size); + + /* "View.MemoryView":1225 + * tmpslice.strides[i] = 0 + * + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: + */ + goto __pyx_L9; + } + + /* "View.MemoryView":1228 + * memcpy(result, src.data, size) + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< + * + * return result + */ + /*else*/ { + copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize); + } + __pyx_L9:; + + /* "View.MemoryView":1230 + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) + * + * return result # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + /* "View.MemoryView":1192 + * + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = NULL; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1235 + * + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + */ + +static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_extents", 0); + + /* "View.MemoryView":1238 + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + * (i, extent1, extent2)) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_err_dim') + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + + /* "View.MemoryView":1237 + * cdef int _err_extents(int i, Py_ssize_t extent1, + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< + * (i, extent1, extent2)) + * + */ + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 1237, __pyx_L1_error) + + /* "View.MemoryView":1235 + * + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1241 + * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) + * + */ + +static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_dim", 0); + __Pyx_INCREF(__pyx_v_error); + + /* "View.MemoryView":1242 + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: + * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_err') + */ + __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_v_error); + __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_2) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1242, __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 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 1242, __pyx_L1_error) + + /* "View.MemoryView":1241 + * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) + * + */ + + /* 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_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1245 + * + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) + */ + +static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err", 0); + __Pyx_INCREF(__pyx_v_error); + + /* "View.MemoryView":1246 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: + */ + __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1247 + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: + * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< + * else: + * raise error + */ + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_error); + __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(2, 1247, __pyx_L1_error) + + /* "View.MemoryView":1246 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: + */ + } + + /* "View.MemoryView":1249 + * raise error(msg.decode('ascii')) + * else: + * raise error # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_contents') + */ + /*else*/ { + __Pyx_Raise(__pyx_v_error, 0, 0, 0); + __PYX_ERR(2, 1249, __pyx_L1_error) + } + + /* "View.MemoryView":1245 + * + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1252 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ + +static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) { + void *__pyx_v_tmpdata; + size_t __pyx_v_itemsize; + int __pyx_v_i; + char __pyx_v_order; + int __pyx_v_broadcasting; + int __pyx_v_direct_copy; + __Pyx_memviewslice __pyx_v_tmp; + int __pyx_v_ndim; + int __pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + void *__pyx_t_6; + int __pyx_t_7; + + /* "View.MemoryView":1260 + * Check for overlapping memory and verify the shapes. + * """ + * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i + */ + __pyx_v_tmpdata = NULL; + + /* "View.MemoryView":1261 + * """ + * cdef void *tmpdata = NULL + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) + */ + __pyx_t_1 = __pyx_v_src.memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":1263 + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< + * cdef bint broadcasting = False + * cdef bint direct_copy = False + */ + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); + + /* "View.MemoryView":1264 + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False # <<<<<<<<<<<<<< + * cdef bint direct_copy = False + * cdef __Pyx_memviewslice tmp + */ + __pyx_v_broadcasting = 0; + + /* "View.MemoryView":1265 + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False + * cdef bint direct_copy = False # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice tmp + * + */ + __pyx_v_direct_copy = 0; + + /* "View.MemoryView":1268 + * cdef __Pyx_memviewslice tmp + * + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + */ + __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1269 + * + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) + */ + __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim); + + /* "View.MemoryView":1268 + * cdef __Pyx_memviewslice tmp + * + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1270 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + */ + __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1271 + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< + * + * cdef int ndim = max(src_ndim, dst_ndim) + */ + __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim); + + /* "View.MemoryView":1270 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + */ + } + __pyx_L3:; + + /* "View.MemoryView":1273 + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + __pyx_t_3 = __pyx_v_dst_ndim; + __pyx_t_4 = __pyx_v_src_ndim; + if (((__pyx_t_3 > __pyx_t_4) != 0)) { + __pyx_t_5 = __pyx_t_3; + } else { + __pyx_t_5 = __pyx_t_4; + } + __pyx_v_ndim = __pyx_t_5; + + /* "View.MemoryView":1275 + * cdef int ndim = max(src_ndim, dst_ndim) + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1276 + * + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True + */ + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1277 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 + */ + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1278 + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: + * broadcasting = True # <<<<<<<<<<<<<< + * src.strides[i] = 0 + * else: + */ + __pyx_v_broadcasting = 1; + + /* "View.MemoryView":1279 + * if src.shape[i] == 1: + * broadcasting = True + * src.strides[i] = 0 # <<<<<<<<<<<<<< + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) + */ + (__pyx_v_src.strides[__pyx_v_i]) = 0; + + /* "View.MemoryView":1277 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 + */ + goto __pyx_L7; + } + + /* "View.MemoryView":1281 + * src.strides[i] = 0 + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< + * + * if src.suboffsets[i] >= 0: + */ + /*else*/ { + __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1281, __pyx_L1_error) + } + __pyx_L7:; + + /* "View.MemoryView":1276 + * + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True + */ + } + + /* "View.MemoryView":1283 + * _err_extents(i, dst.shape[i], src.shape[i]) + * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + */ + __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1284 + * + * if src.suboffsets[i] >= 0: + * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< + * + * if slices_overlap(&src, &dst, ndim, itemsize): + */ + __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1284, __pyx_L1_error) + + /* "View.MemoryView":1283 + * _err_extents(i, dst.shape[i], src.shape[i]) + * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + */ + } + } + + /* "View.MemoryView":1286 + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + * + * if not slice_is_contig(src, order, ndim): + */ + __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1288 + * if slices_overlap(&src, &dst, ndim, itemsize): + * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) + * + */ + __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1289 + * + * if not slice_is_contig(src, order, ndim): + * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + */ + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim); + + /* "View.MemoryView":1288 + * if slices_overlap(&src, &dst, ndim, itemsize): + * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) + * + */ + } + + /* "View.MemoryView":1291 + * order = get_best_order(&dst, ndim) + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< + * src = tmp + * + */ + __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 1291, __pyx_L1_error) + __pyx_v_tmpdata = __pyx_t_6; + + /* "View.MemoryView":1292 + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + * src = tmp # <<<<<<<<<<<<<< + * + * if not broadcasting: + */ + __pyx_v_src = __pyx_v_tmp; + + /* "View.MemoryView":1286 + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + * + * if not slice_is_contig(src, order, ndim): + */ + } + + /* "View.MemoryView":1294 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1297 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1298 + * + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<< + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim); + + /* "View.MemoryView":1297 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + goto __pyx_L12; + } + + /* "View.MemoryView":1299 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1300 + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<< + * + * if direct_copy: + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim); + + /* "View.MemoryView":1299 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ + } + __pyx_L12:; + + /* "View.MemoryView":1302 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_2 = (__pyx_v_direct_copy != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1304 + * if direct_copy: + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1305 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + */ + memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)); + + /* "View.MemoryView":1306 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * free(tmpdata) + * return 0 + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1307 + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1308 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * if order == 'F' == get_best_order(&dst, ndim): + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1302 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + } + + /* "View.MemoryView":1294 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":1310 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = (__pyx_v_order == 'F'); + if (__pyx_t_2) { + __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim)); + } + __pyx_t_7 = (__pyx_t_2 != 0); + if (__pyx_t_7) { + + /* "View.MemoryView":1313 + * + * + * transpose_memslice(&src) # <<<<<<<<<<<<<< + * transpose_memslice(&dst) + * + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1313, __pyx_L1_error) + + /* "View.MemoryView":1314 + * + * transpose_memslice(&src) + * transpose_memslice(&dst) # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1314, __pyx_L1_error) + + /* "View.MemoryView":1310 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":1316 + * transpose_memslice(&dst) + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1317 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + */ + copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); + + /* "View.MemoryView":1318 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * free(tmpdata) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1320 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1321 + * + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_broadcast_leading') + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1252 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1324 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { + int __pyx_v_i; + int __pyx_v_offset; + int __pyx_t_1; + int __pyx_t_2; + + /* "View.MemoryView":1328 + * int ndim_other) nogil: + * cdef int i + * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< + * + * for i in range(ndim - 1, -1, -1): + */ + __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); + + /* "View.MemoryView":1330 + * cdef int offset = ndim_other - ndim + * + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":1331 + * + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + */ + (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); + + /* "View.MemoryView":1332 + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + */ + (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1333 + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< + * + * for i in range(offset): + */ + (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); + } + + /* "View.MemoryView":1335 + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + * for i in range(offset): # <<<<<<<<<<<<<< + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + */ + __pyx_t_1 = __pyx_v_offset; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "View.MemoryView":1336 + * + * for i in range(offset): + * mslice.shape[i] = 1 # <<<<<<<<<<<<<< + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 + */ + (__pyx_v_mslice->shape[__pyx_v_i]) = 1; + + /* "View.MemoryView":1337 + * for i in range(offset): + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< + * mslice.suboffsets[i] = -1 + * + */ + (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); + + /* "View.MemoryView":1338 + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; + } + + /* "View.MemoryView":1324 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1346 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + +static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { + int __pyx_t_1; + + /* "View.MemoryView":1350 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + __pyx_t_1 = (__pyx_v_dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1351 + * + * if dtype_is_object: + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< + * dst.strides, ndim, inc) + * + */ + __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1350 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + } + + /* "View.MemoryView":1346 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + + /* function exit code */ +} + +/* "View.MemoryView":1355 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + +static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + __Pyx_RefNannyDeclarations + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); + + /* "View.MemoryView":1358 + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1355 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif +} + +/* "View.MemoryView":1361 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + +static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); + + /* "View.MemoryView":1365 + * cdef Py_ssize_t i + * + * for i in range(shape[0]): # <<<<<<<<<<<<<< + * if ndim == 1: + * if inc: + */ + __pyx_t_1 = (__pyx_v_shape[0]); + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "View.MemoryView":1366 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + __pyx_t_3 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":1367 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + __pyx_t_3 = (__pyx_v_inc != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":1368 + * if ndim == 1: + * if inc: + * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * Py_DECREF(( data)[0]) + */ + Py_INCREF((((PyObject **)__pyx_v_data)[0])); + + /* "View.MemoryView":1367 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + goto __pyx_L6; + } + + /* "View.MemoryView":1370 + * Py_INCREF(( data)[0]) + * else: + * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + */ + /*else*/ { + Py_DECREF((((PyObject **)__pyx_v_data)[0])); + } + __pyx_L6:; + + /* "View.MemoryView":1366 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + goto __pyx_L5; + } + + /* "View.MemoryView":1372 + * Py_DECREF(( data)[0]) + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, inc) + * + */ + /*else*/ { + + /* "View.MemoryView":1373 + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + * ndim - 1, inc) # <<<<<<<<<<<<<< + * + * data += strides[0] + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc); + } + __pyx_L5:; + + /* "View.MemoryView":1375 + * ndim - 1, inc) + * + * data += strides[0] # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); + } + + /* "View.MemoryView":1361 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1381 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + +static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { + + /* "View.MemoryView":1384 + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1385 + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1387 + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1381 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + +static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_extent; + int __pyx_t_1; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + + /* "View.MemoryView":1395 + * size_t itemsize, void *item) nogil: + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t extent = shape[0] + * + */ + __pyx_v_stride = (__pyx_v_strides[0]); + + /* "View.MemoryView":1396 + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] + * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< + * + * if ndim == 1: + */ + __pyx_v_extent = (__pyx_v_shape[0]); + + /* "View.MemoryView":1398 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1399 + * + * if ndim == 1: + * for i in range(extent): # <<<<<<<<<<<<<< + * memcpy(data, item, itemsize) + * data += stride + */ + __pyx_t_2 = __pyx_v_extent; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1400 + * if ndim == 1: + * for i in range(extent): + * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< + * data += stride + * else: + */ + memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize); + + /* "View.MemoryView":1401 + * for i in range(extent): + * memcpy(data, item, itemsize) + * data += stride # <<<<<<<<<<<<<< + * else: + * for i in range(extent): + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + + /* "View.MemoryView":1398 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1403 + * data += stride + * else: + * for i in range(extent): # <<<<<<<<<<<<<< + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + */ + /*else*/ { + __pyx_t_2 = __pyx_v_extent; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1404 + * else: + * for i in range(extent): + * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, itemsize, item) + * data += stride + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1406 + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + * data += stride # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + } + __pyx_L3:; + + /* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + + /* function exit code */ +} +static struct __pyx_vtabstruct_array __pyx_vtable_array; + +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_array_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_array_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_array; + p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_array(PyObject *o) { + struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_array___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->mode); + Py_CLEAR(p->_format); + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_array___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) { + PyObject *v = PyObject_GenericGetAttr(o, n); + if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + v = __pyx_array___getattr__(o, n); + } + return v; +} + +static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o); +} + +static PyMethodDef __pyx_methods_array[] = { + {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_array[] = { + {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_array = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_array, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_array = { + 0, /*mp_length*/ + __pyx_array___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_array = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_array_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_array = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.array", /*tp_name*/ + sizeof(struct __pyx_array_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_array, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_array, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_array, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + __pyx_tp_getattro_array, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_array, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_array, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_array, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_array, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_MemviewEnum_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_MemviewEnum_obj *)o); + p->name = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_Enum(PyObject *o) { + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->name); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + if (p->name) { + e = (*v)(p->name, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_Enum(PyObject *o) { + PyObject* tmp; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + tmp = ((PyObject*)p->name); + p->name = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_Enum[] = { + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_MemviewEnum = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.Enum", /*tp_name*/ + sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_Enum, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_MemviewEnum___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_Enum, /*tp_traverse*/ + __pyx_tp_clear_Enum, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_Enum, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_MemviewEnum___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_Enum, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview; + +static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryview_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryview_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_memoryview; + p->obj = Py_None; Py_INCREF(Py_None); + p->_size = Py_None; Py_INCREF(Py_None); + p->_array_interface = Py_None; Py_INCREF(Py_None); + p->view.obj = NULL; + if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_memoryview(PyObject *o) { + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_memoryview___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->obj); + Py_CLEAR(p->_size); + Py_CLEAR(p->_array_interface); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + if (p->obj) { + e = (*v)(p->obj, a); if (e) return e; + } + if (p->_size) { + e = (*v)(p->_size, a); if (e) return e; + } + if (p->_array_interface) { + e = (*v)(p->_array_interface, a); if (e) return e; + } + if (p->view.obj) { + e = (*v)(p->view.obj, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_memoryview(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + tmp = ((PyObject*)p->obj); + p->obj = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_size); + p->_size = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_array_interface); + p->_array_interface = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + Py_CLEAR(p->view.obj); + return 0; +} +static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_memoryview___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o); +} + +static PyMethodDef __pyx_methods_memoryview[] = { + {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0}, + {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, + {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, + {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_memoryview[] = { + {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0}, + {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0}, + {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0}, + {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0}, + {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0}, + {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0}, + {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0}, + {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0}, + {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_memoryview = { + __pyx_memoryview___len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_memoryview, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_memoryview = { + __pyx_memoryview___len__, /*mp_length*/ + __pyx_memoryview___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_memoryview = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_memoryview_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_memoryview = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.memoryview", /*tp_name*/ + sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_memoryview, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_memoryview___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_memoryview___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_memoryview, /*tp_traverse*/ + __pyx_tp_clear_memoryview, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_memoryview, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_memoryview, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_memoryview, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice; + +static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryviewslice_obj *p; + PyObject *o = __pyx_tp_new_memoryview(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryviewslice_obj *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice; + p->from_object = Py_None; Py_INCREF(Py_None); + p->from_slice.memview = NULL; + return o; +} + +static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_memoryviewslice___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->from_object); + PyObject_GC_Track(o); + __pyx_tp_dealloc_memoryview(o); +} + +static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e; + if (p->from_object) { + e = (*v)(p->from_object, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear__memoryviewslice(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + __pyx_tp_clear_memoryview(o); + tmp = ((PyObject*)p->from_object); + p->from_object = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + __PYX_XDEC_MEMVIEW(&p->from_slice, 1); + return 0; +} + +static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o); +} + +static PyMethodDef __pyx_methods__memoryviewslice[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = { + {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_memoryviewslice = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance._memoryviewslice", /*tp_name*/ + sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___str__, /*tp_str*/ + #else + 0, /*tp_str*/ + #endif + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Internal class for passing memoryview slices to Python", /*tp_doc*/ + __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/ + __pyx_tp_clear__memoryviewslice, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods__memoryviewslice, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets__memoryviewslice, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new__memoryviewslice, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "_distance", + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1}, + {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0}, + {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0}, + {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1}, + {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, + {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0}, + {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0}, + {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, + {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, + {&__pyx_n_s_Orange_distance__distance, __pyx_k_Orange_distance__distance, sizeof(__pyx_k_Orange_distance__distance), 0, 0, 1, 1}, + {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s__29, __pyx_k__29, sizeof(__pyx_k__29), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, + {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, + {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, + {&__pyx_kp_s_cannot_normalize_the_data_has_no, __pyx_k_cannot_normalize_the_data_has_no, sizeof(__pyx_k_cannot_normalize_the_data_has_no), 0, 0, 1, 0}, + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, + {&__pyx_n_s_col1, __pyx_k_col1, sizeof(__pyx_k_col1), 0, 0, 1, 1}, + {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, + {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, + {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, + {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, + {&__pyx_n_s_distances, __pyx_k_distances, sizeof(__pyx_k_distances), 0, 0, 1, 1}, + {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1}, + {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, + {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, + {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, + {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, + {&__pyx_n_s_euclidean_cols, __pyx_k_euclidean_cols, sizeof(__pyx_k_euclidean_cols), 0, 0, 1, 1}, + {&__pyx_n_s_euclidean_rows, __pyx_k_euclidean_rows, sizeof(__pyx_k_euclidean_rows), 0, 0, 1, 1}, + {&__pyx_n_s_fit_jaccard, __pyx_k_fit_jaccard, sizeof(__pyx_k_fit_jaccard), 0, 0, 1, 1}, + {&__pyx_n_s_fit_params, __pyx_k_fit_params, sizeof(__pyx_k_fit_params), 0, 0, 1, 1}, + {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, + {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, + {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, + {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, + {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_in1_unk2, __pyx_k_in1_unk2, sizeof(__pyx_k_in1_unk2), 0, 0, 1, 1}, + {&__pyx_n_s_in_both, __pyx_k_in_both, sizeof(__pyx_k_in_both), 0, 0, 1, 1}, + {&__pyx_n_s_in_one, __pyx_k_in_one, sizeof(__pyx_k_in_one), 0, 0, 1, 1}, + {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, + {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1}, + {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, + {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, + {&__pyx_n_s_ival1, __pyx_k_ival1, sizeof(__pyx_k_ival1), 0, 0, 1, 1}, + {&__pyx_n_s_ival2, __pyx_k_ival2, sizeof(__pyx_k_ival2), 0, 0, 1, 1}, + {&__pyx_n_s_jaccard_cols, __pyx_k_jaccard_cols, sizeof(__pyx_k_jaccard_cols), 0, 0, 1, 1}, + {&__pyx_n_s_jaccard_rows, __pyx_k_jaccard_rows, sizeof(__pyx_k_jaccard_rows), 0, 0, 1, 1}, + {&__pyx_n_s_mads, __pyx_k_mads, sizeof(__pyx_k_mads), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_manhattan_cols, __pyx_k_manhattan_cols, sizeof(__pyx_k_manhattan_cols), 0, 0, 1, 1}, + {&__pyx_n_s_manhattan_rows, __pyx_k_manhattan_rows, sizeof(__pyx_k_manhattan_rows), 0, 0, 1, 1}, + {&__pyx_n_s_means, __pyx_k_means, sizeof(__pyx_k_means), 0, 0, 1, 1}, + {&__pyx_n_s_medians, __pyx_k_medians, sizeof(__pyx_k_medians), 0, 0, 1, 1}, + {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, + {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, + {&__pyx_n_s_n_cols, __pyx_k_n_cols, sizeof(__pyx_k_n_cols), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows, __pyx_k_n_rows, sizeof(__pyx_k_n_rows), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows1, __pyx_k_n_rows1, sizeof(__pyx_k_n_rows1), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows2, __pyx_k_n_rows2, sizeof(__pyx_k_n_rows2), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, + {&__pyx_n_s_nonnans, __pyx_k_nonnans, sizeof(__pyx_k_nonnans), 0, 0, 1, 1}, + {&__pyx_n_s_nonzeros, __pyx_k_nonzeros, sizeof(__pyx_k_nonzeros), 0, 0, 1, 1}, + {&__pyx_n_s_normalize, __pyx_k_normalize, sizeof(__pyx_k_normalize), 0, 0, 1, 1}, + {&__pyx_n_s_not1_unk2, __pyx_k_not1_unk2, sizeof(__pyx_k_not1_unk2), 0, 0, 1, 1}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, + {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, + {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, + {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 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_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, + {&__pyx_n_s_row1, __pyx_k_row1, sizeof(__pyx_k_row1), 0, 0, 1, 1}, + {&__pyx_n_s_row2, __pyx_k_row2, sizeof(__pyx_k_row2), 0, 0, 1, 1}, + {&__pyx_n_s_same, __pyx_k_same, sizeof(__pyx_k_same), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, + {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, + {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, + {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1}, + {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, + {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, + {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, + {&__pyx_n_s_union, __pyx_k_union, sizeof(__pyx_k_union), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_in2, __pyx_k_unk1_in2, sizeof(__pyx_k_unk1_in2), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_not2, __pyx_k_unk1_not2, sizeof(__pyx_k_unk1_not2), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_unk2, __pyx_k_unk1_unk2, sizeof(__pyx_k_unk1_unk2), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, + {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1}, + {&__pyx_n_s_val1, __pyx_k_val1, sizeof(__pyx_k_val1), 0, 0, 1, 1}, + {&__pyx_n_s_val2, __pyx_k_val2, sizeof(__pyx_k_val2), 0, 0, 1, 1}, + {&__pyx_n_s_vars, __pyx_k_vars, sizeof(__pyx_k_vars), 0, 0, 1, 1}, + {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, + {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1}, + {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1}, + {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 21, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) + __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 396, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 425, __pyx_L1_error) + __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 599, __pyx_L1_error) + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 818, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "Orange/distance/_distance.pyx":23 + * for col in range(dividers.shape[0]): + * if dividers[col] == 0 and not x[:, col].isnan().all(): + * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * if ((descr.byteorder == c'>' and little_endian) or + * (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" + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "View.MemoryView":131 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "View.MemoryView":134 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "View.MemoryView":137 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "View.MemoryView":146 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "View.MemoryView":174 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "View.MemoryView":190 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + /* "View.MemoryView":484 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 484, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + /* "View.MemoryView":556 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + */ + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + + /* "View.MemoryView":563 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + */ + __pyx_tuple__16 = PyTuple_New(1); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_tuple__16, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__16); + + /* "View.MemoryView":668 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: + */ + __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__17); + __Pyx_GIVEREF(__pyx_slice__17); + + /* "View.MemoryView":671 + * seen_ellipsis = True + * else: + * result.append(slice(None)) # <<<<<<<<<<<<<< + * have_slices = True + * else: + */ + __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 671, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + + /* "View.MemoryView":682 + * nslices = ndim - len(result) + * if nslices: + * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + * + * return have_slices or nslices, tuple(result) + */ + __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + + /* "View.MemoryView":689 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + + /* "Orange/distance/_distance.pyx":33 + * + * + * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_tuple__21 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances, __pyx_n_s_same); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 33, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":93 + * + * + * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] means = fit_params["means"] + */ + __pyx_tuple__23 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); + __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 93, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":138 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_tuple__25 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_same, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__25); + __Pyx_GIVEREF(__pyx_tuple__25); + __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 138, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":200 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + __pyx_tuple__27 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 200, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__27); + __Pyx_GIVEREF(__pyx_tuple__27); + __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 200, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":244 + * + * + * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * cdef: + * int row, n_cols, nonzeros, nonnans + */ + __pyx_tuple__30 = PyTuple_Pack(9, __pyx_n_s_x, __pyx_n_s__29, __pyx_n_s_row, __pyx_n_s_n_cols, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val, __pyx_n_s_ps, __pyx_n_s_col); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fit_jaccard, 244, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 244, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":264 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_tuple__32 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_same, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); + __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(3, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 264, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":314 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + __pyx_tuple__34 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__34); + __Pyx_GIVEREF(__pyx_tuple__34); + __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 314, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 314, __pyx_L1_error) + + /* "View.MemoryView":282 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__36); + __Pyx_GIVEREF(__pyx_tuple__36); + + /* "View.MemoryView":283 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + + /* "View.MemoryView":284 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__38); + __Pyx_GIVEREF(__pyx_tuple__38); + + /* "View.MemoryView":287 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + + /* "View.MemoryView":288 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__40); + __Pyx_GIVEREF(__pyx_tuple__40); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_distance(void); /*proto*/ +PyMODINIT_FUNC init_distance(void) +#else +PyMODINIT_FUNC PyInit__distance(void); /*proto*/ +PyMODINIT_FUNC PyInit__distance(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + static PyThread_type_lock __pyx_t_2[8]; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__distance(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("_distance", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_Orange__distance___distance) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "Orange.distance._distance")) { + if (unlikely(PyDict_SetItemString(modules, "Orange.distance._distance", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + generic = Py_None; Py_INCREF(Py_None); + strided = Py_None; Py_INCREF(Py_None); + indirect = Py_None; Py_INCREF(Py_None); + contiguous = Py_None; Py_INCREF(Py_None); + indirect_contiguous = Py_None; Py_INCREF(Py_None); + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_array = &__pyx_vtable_array; + __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; + if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) + __pyx_type___pyx_array.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) + __pyx_array_type = &__pyx_type___pyx_array; + if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 275, __pyx_L1_error) + __pyx_type___pyx_MemviewEnum.tp_print = 0; + __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; + __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; + __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; + __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice; + __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment; + __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar; + __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed; + __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object; + __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object; + if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) + __pyx_type___pyx_memoryview.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) + __pyx_memoryview_type = &__pyx_type___pyx_memoryview; + __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; + __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; + __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; + __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; + __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; + if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) + __pyx_type___pyx_memoryviewslice.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) + __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "Orange/distance/_distance.pyx":7 + * #cython: wraparound=False + * + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":33 + * + * + * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":93 + * + * + * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] means = fit_params["means"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":138 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":200 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 200, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":244 + * + * + * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * cdef: + * int row, n_cols, nonzeros, nonnans + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9fit_jaccard, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fit_jaccard, __pyx_t_1) < 0) __PYX_ERR(0, 244, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":264 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * fit_params): + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":314 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":1 + * #cython: embedsignature=True # <<<<<<<<<<<<<< + * #cython: infer_types=True + * #cython: cdivision=True + */ + __pyx_t_1 = PyDict_New(); 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; + + /* "View.MemoryView":207 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * def __dealloc__(array self): + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 207, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_array_type); + + /* "View.MemoryView":282 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(generic); + __Pyx_DECREF_SET(generic, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":283 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(strided); + __Pyx_DECREF_SET(strided, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":284 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(indirect); + __Pyx_DECREF_SET(indirect, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":287 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(contiguous); + __Pyx_DECREF_SET(contiguous, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":288 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(indirect_contiguous); + __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":312 + * + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<< + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ + * PyThread_allocate_lock(), + */ + __pyx_memoryview_thread_locks_used = 0; + + /* "View.MemoryView":313 + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<< + * PyThread_allocate_lock(), + * PyThread_allocate_lock(), + */ + __pyx_t_2[0] = PyThread_allocate_lock(); + __pyx_t_2[1] = PyThread_allocate_lock(); + __pyx_t_2[2] = PyThread_allocate_lock(); + __pyx_t_2[3] = PyThread_allocate_lock(); + __pyx_t_2[4] = PyThread_allocate_lock(); + __pyx_t_2[5] = PyThread_allocate_lock(); + __pyx_t_2[6] = PyThread_allocate_lock(); + __pyx_t_2[7] = PyThread_allocate_lock(); + memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); + + /* "View.MemoryView":535 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 535, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 535, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_memoryview_type); + + /* "View.MemoryView":981 + * return self.from_object + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 981, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 981, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_memoryviewslice_type); + + /* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init Orange.distance._distance", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init Orange.distance._distance"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* BufferFormatCheck */ +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; + } + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; + } + case 's': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +/* MemviewSliceInit */ + static int +__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference) +{ + __Pyx_RefNannyDeclarations + int i, retval=-1; + Py_buffer *buf = &memview->view; + __Pyx_RefNannySetupContext("init_memviewslice", 0); + if (!buf) { + PyErr_SetString(PyExc_ValueError, + "buf is NULL."); + goto fail; + } else if (memviewslice->memview || memviewslice->data) { + PyErr_SetString(PyExc_ValueError, + "memviewslice is already initialized!"); + goto fail; + } + if (buf->strides) { + for (i = 0; i < ndim; i++) { + memviewslice->strides[i] = buf->strides[i]; + } + } else { + Py_ssize_t stride = buf->itemsize; + for (i = ndim - 1; i >= 0; i--) { + memviewslice->strides[i] = stride; + stride *= buf->shape[i]; + } + } + for (i = 0; i < ndim; i++) { + memviewslice->shape[i] = buf->shape[i]; + if (buf->suboffsets) { + memviewslice->suboffsets[i] = buf->suboffsets[i]; + } else { + memviewslice->suboffsets[i] = -1; + } + } + memviewslice->memview = memview; + memviewslice->data = (char *)buf->buf; + if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { + Py_INCREF(memview); + } + retval = 0; + goto no_fail; +fail: + memviewslice->memview = 0; + memviewslice->data = 0; + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} +static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) { + va_list vargs; + char msg[200]; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, fmt); +#else + va_start(vargs); +#endif + vsnprintf(msg, 200, fmt, vargs); + Py_FatalError(msg); + va_end(vargs); +} +static CYTHON_INLINE int +__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)++; + PyThread_release_lock(lock); + return result; +} +static CYTHON_INLINE int +__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)--; + PyThread_release_lock(lock); + return result; +} +static CYTHON_INLINE void +__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno) +{ + int first_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (!memview || (PyObject *) memview == Py_None) + return; + if (__pyx_get_slice_count(memview) < 0) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + first_time = __pyx_add_acquisition_count(memview) == 0; + if (first_time) { + if (have_gil) { + Py_INCREF((PyObject *) memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_INCREF((PyObject *) memview); + PyGILState_Release(_gilstate); + } + } +} +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, + int have_gil, int lineno) { + int last_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (!memview ) { + return; + } else if ((PyObject *) memview == Py_None) { + memslice->memview = NULL; + return; + } + if (__pyx_get_slice_count(memview) <= 0) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + last_time = __pyx_sub_acquisition_count(memview) == 1; + memslice->data = NULL; + if (last_time) { + if (have_gil) { + Py_CLEAR(memslice->memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_CLEAR(memslice->memview); + PyGILState_Release(_gilstate); + } + } else { + memslice->memview = NULL; + } +} + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* PyErrFetchRestore */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* RaiseArgTupleInvalid */ + static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ + static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ + static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* ArgTypeTest */ + static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; + } + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; +} + +/* GetModuleGlobalName */ + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseNoneIterError */ + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* BytesEquals */ + static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else + if (s1 == s2) { + return (equals == Py_EQ); + } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { + const char *ps1, *ps2; + Py_ssize_t length = PyBytes_GET_SIZE(s1); + if (length != PyBytes_GET_SIZE(s2)) + return (equals == Py_NE); + ps1 = PyBytes_AS_STRING(s1); + ps2 = PyBytes_AS_STRING(s2); + if (ps1[0] != ps2[0]) { + return (equals == Py_NE); + } else if (length == 1) { + return (equals == Py_EQ); + } else { + int result = memcmp(ps1, ps2, (size_t)length); + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { + return (equals == Py_NE); + } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { + return (equals == Py_NE); + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +#endif +} + +/* UnicodeEquals */ + static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else +#if PY_MAJOR_VERSION < 3 + PyObject* owned_ref = NULL; +#endif + int s1_is_unicode, s2_is_unicode; + if (s1 == s2) { + goto return_eq; + } + s1_is_unicode = PyUnicode_CheckExact(s1); + s2_is_unicode = PyUnicode_CheckExact(s2); +#if PY_MAJOR_VERSION < 3 + if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { + owned_ref = PyUnicode_FromObject(s2); + if (unlikely(!owned_ref)) + return -1; + s2 = owned_ref; + s2_is_unicode = 1; + } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { + owned_ref = PyUnicode_FromObject(s1); + if (unlikely(!owned_ref)) + return -1; + s1 = owned_ref; + s1_is_unicode = 1; + } else if (((!s2_is_unicode) & (!s1_is_unicode))) { + return __Pyx_PyBytes_Equals(s1, s2, equals); + } +#endif + if (s1_is_unicode & s2_is_unicode) { + Py_ssize_t length; + int kind; + void *data1, *data2; + if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) + return -1; + length = __Pyx_PyUnicode_GET_LENGTH(s1); + if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { + goto return_ne; + } + kind = __Pyx_PyUnicode_KIND(s1); + if (kind != __Pyx_PyUnicode_KIND(s2)) { + goto return_ne; + } + data1 = __Pyx_PyUnicode_DATA(s1); + data2 = __Pyx_PyUnicode_DATA(s2); + if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { + goto return_ne; + } else if (length == 1) { + goto return_eq; + } else { + int result = memcmp(data1, data2, (size_t)(length * kind)); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & s2_is_unicode) { + goto return_ne; + } else if ((s2 == Py_None) & s1_is_unicode) { + goto return_ne; + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +return_eq: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ); +return_ne: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_NE); +#endif +} + +/* GetAttr */ + static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { +#if CYTHON_COMPILING_IN_CPYTHON +#if PY_MAJOR_VERSION >= 3 + if (likely(PyUnicode_Check(n))) +#else + if (likely(PyString_Check(n))) +#endif + return __Pyx_PyObject_GetAttrStr(o, n); +#endif + return PyObject_GetAttr(o, n); +} + +/* decode_c_string */ + static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + Py_ssize_t length; + if (unlikely((start < 0) | (stop < 0))) { + size_t slen = strlen(cstring); + if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, + "c-string too long to convert to Python"); + return NULL; + } + length = (Py_ssize_t) slen; + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + length = stop - start; + if (unlikely(length <= 0)) + return PyUnicode_FromUnicode(NULL, 0); + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* SaveResetException */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + return PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_COMPILING_IN_CPYTHON + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* SwapException */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* Import */ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* GetItemInt */ + static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* PyIntBinop */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* None */ + static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} + +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* SetVTable */ + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + if (PyObject_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags); + if (PyObject_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags); + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + Py_DECREF(obj); + view->obj = NULL; +} +#endif + + + /* MemviewSliceIsContig */ + static int +__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, + char order, int ndim) +{ + int i, index, step, start; + Py_ssize_t itemsize = mvs.memview->view.itemsize; + if (order == 'F') { + step = 1; + start = 0; + } else { + step = -1; + start = ndim - 1; + } + for (i = 0; i < ndim; i++) { + index = start + step * i; + if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) + return 0; + itemsize *= mvs.shape[index]; + } + return 1; +} + +/* OverlappingSlices */ + static void +__pyx_get_array_memory_extents(__Pyx_memviewslice *slice, + void **out_start, void **out_end, + int ndim, size_t itemsize) +{ + char *start, *end; + int i; + start = end = slice->data; + for (i = 0; i < ndim; i++) { + Py_ssize_t stride = slice->strides[i]; + Py_ssize_t extent = slice->shape[i]; + if (extent == 0) { + *out_start = *out_end = start; + return; + } else { + if (stride > 0) + end += stride * (extent - 1); + else + start += stride * (extent - 1); + } + } + *out_start = start; + *out_end = end + itemsize; +} +static int +__pyx_slices_overlap(__Pyx_memviewslice *slice1, + __Pyx_memviewslice *slice2, + int ndim, size_t itemsize) +{ + void *start1, *end1, *start2, *end2; + __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); + __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); + return (start1 < end2) && (start2 < end1); +} + +/* Capsule */ + static CYTHON_INLINE PyObject * +__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) +{ + PyObject *cobj; +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(p, sig, NULL); +#else + cobj = PyCObject_FromVoidPtr(p, NULL); +#endif + return cobj; +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* MemviewDtypeToObject */ + static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) { + return (PyObject *) PyFloat_FromDouble(*(double *) itemp); +} +static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) { + double value = __pyx_PyFloat_AsDouble(obj); + if ((value == (double)-1) && PyErr_Occurred()) + return 0; + *(double *) itemp = value; + return 1; +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* None */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* None */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +/* None */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* None */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(enum NPY_TYPES) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(enum NPY_TYPES) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), + little, !is_unsigned); + } +} + +/* MemviewSliceCopyTemplate */ + static __Pyx_memviewslice +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object) +{ + __Pyx_RefNannyDeclarations + int i; + __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } }; + struct __pyx_memoryview_obj *from_memview = from_mvs->memview; + Py_buffer *buf = &from_memview->view; + PyObject *shape_tuple = NULL; + PyObject *temp_int = NULL; + struct __pyx_array_obj *array_obj = NULL; + struct __pyx_memoryview_obj *memview_obj = NULL; + __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0); + for (i = 0; i < ndim; i++) { + if (from_mvs->suboffsets[i] >= 0) { + PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with " + "indirect dimensions (axis %d)", i); + goto fail; + } + } + shape_tuple = PyTuple_New(ndim); + if (unlikely(!shape_tuple)) { + goto fail; + } + __Pyx_GOTREF(shape_tuple); + for(i = 0; i < ndim; i++) { + temp_int = PyInt_FromSsize_t(from_mvs->shape[i]); + if(unlikely(!temp_int)) { + goto fail; + } else { + PyTuple_SET_ITEM(shape_tuple, i, temp_int); + temp_int = NULL; + } + } + array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL); + if (unlikely(!array_obj)) { + goto fail; + } + __Pyx_GOTREF(array_obj); + memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + (PyObject *) array_obj, contig_flag, + dtype_is_object, + from_mvs->memview->typeinfo); + if (unlikely(!memview_obj)) + goto fail; + if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0)) + goto fail; + if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim, + dtype_is_object) < 0)) + goto fail; + goto no_fail; +fail: + __Pyx_XDECREF(new_mvs.memview); + new_mvs.memview = NULL; + new_mvs.data = NULL; +no_fail: + __Pyx_XDECREF(shape_tuple); + __Pyx_XDECREF(temp_int); + __Pyx_XDECREF(array_obj); + __Pyx_RefNannyFinishContext(); + return new_mvs; +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { + const char neg_one = (char) -1, const_zero = (char) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(char) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (char) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (char) 0; + case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0]) + case 2: + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { + return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { + return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { + return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (char) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(char) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (char) 0; + case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0]) + case -2: + if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + } +#endif + if (sizeof(char) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) + } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + char val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (char) -1; + } + } else { + char val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (char) -1; + val = __Pyx_PyInt_As_char(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to char"); + return (char) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to char"); + return (char) -1; +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* TypeInfoCompare */ + static int +__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) +{ + int i; + if (!a || !b) + return 0; + if (a == b) + return 1; + if (a->size != b->size || a->typegroup != b->typegroup || + a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) { + if (a->typegroup == 'H' || b->typegroup == 'H') { + return a->size == b->size; + } else { + return 0; + } + } + if (a->ndim) { + for (i = 0; i < a->ndim; i++) + if (a->arraysize[i] != b->arraysize[i]) + return 0; + } + if (a->typegroup == 'S') { + if (a->flags != b->flags) + return 0; + if (a->fields || b->fields) { + if (!(a->fields && b->fields)) + return 0; + for (i = 0; a->fields[i].type && b->fields[i].type; i++) { + __Pyx_StructField *field_a = a->fields + i; + __Pyx_StructField *field_b = b->fields + i; + if (field_a->offset != field_b->offset || + !__pyx_typeinfo_cmp(field_a->type, field_b->type)) + return 0; + } + return !a->fields[i].type && !b->fields[i].type; + } + } + return 1; +} + +/* MemviewSliceValidateAndInit */ + static int +__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec) +{ + if (buf->shape[dim] <= 1) + return 1; + if (buf->strides) { + if (spec & __Pyx_MEMVIEW_CONTIG) { + if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) { + if (buf->strides[dim] != sizeof(void *)) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly contiguous " + "in dimension %d.", dim); + goto fail; + } + } else if (buf->strides[dim] != buf->itemsize) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + if (spec & __Pyx_MEMVIEW_FOLLOW) { + Py_ssize_t stride = buf->strides[dim]; + if (stride < 0) + stride = -stride; + if (stride < buf->itemsize) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + } else { + if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not contiguous in " + "dimension %d", dim); + goto fail; + } else if (spec & (__Pyx_MEMVIEW_PTR)) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not indirect in " + "dimension %d", dim); + goto fail; + } else if (buf->suboffsets) { + PyErr_SetString(PyExc_ValueError, + "Buffer exposes suboffsets but no strides"); + goto fail; + } + } + return 1; +fail: + return 0; +} +static int +__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec) +{ + if (spec & __Pyx_MEMVIEW_DIRECT) { + if (buf->suboffsets && buf->suboffsets[dim] >= 0) { + PyErr_Format(PyExc_ValueError, + "Buffer not compatible with direct access " + "in dimension %d.", dim); + goto fail; + } + } + if (spec & __Pyx_MEMVIEW_PTR) { + if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly accessible " + "in dimension %d.", dim); + goto fail; + } + } + return 1; +fail: + return 0; +} +static int +__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag) +{ + int i; + if (c_or_f_flag & __Pyx_IS_F_CONTIG) { + Py_ssize_t stride = 1; + for (i = 0; i < ndim; i++) { + if (stride * buf->itemsize != buf->strides[i] && + buf->shape[i] > 1) + { + PyErr_SetString(PyExc_ValueError, + "Buffer not fortran contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) { + Py_ssize_t stride = 1; + for (i = ndim - 1; i >- 1; i--) { + if (stride * buf->itemsize != buf->strides[i] && + buf->shape[i] > 1) { + PyErr_SetString(PyExc_ValueError, + "Buffer not C contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } + return 1; +fail: + return 0; +} +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj) +{ + struct __pyx_memoryview_obj *memview, *new_memview; + __Pyx_RefNannyDeclarations + Py_buffer *buf; + int i, spec = 0, retval = -1; + __Pyx_BufFmt_Context ctx; + int from_memoryview = __pyx_memoryview_check(original_obj); + __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0); + if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *) + original_obj)->typeinfo)) { + memview = (struct __pyx_memoryview_obj *) original_obj; + new_memview = NULL; + } else { + memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + original_obj, buf_flags, 0, dtype); + new_memview = memview; + if (unlikely(!memview)) + goto fail; + } + buf = &memview->view; + if (buf->ndim != ndim) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + ndim, buf->ndim); + goto fail; + } + if (new_memview) { + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned) buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) " + "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)", + buf->itemsize, + (buf->itemsize > 1) ? "s" : "", + dtype->name, + dtype->size, + (dtype->size > 1) ? "s" : ""); + goto fail; + } + for (i = 0; i < ndim; i++) { + spec = axes_specs[i]; + if (!__pyx_check_strides(buf, i, ndim, spec)) + goto fail; + if (!__pyx_check_suboffsets(buf, i, ndim, spec)) + goto fail; + } + if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)) + goto fail; + if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice, + new_memview != NULL) == -1)) { + goto fail; + } + retval = 0; + goto no_fail; +fail: + Py_XDECREF(new_memview); + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} + +/* ObjectToMemviewSlice */ + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) { + __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_BufFmt_StackElem stack[1]; + int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; + int retcode; + if (obj == Py_None) { + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, + PyBUF_RECORDS, 1, + &__Pyx_TypeInfo_double, stack, + &result, obj); + if (unlikely(retcode == -1)) + goto __pyx_fail; + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; +} + +/* ObjectToMemviewSlice */ + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj) { + __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_BufFmt_StackElem stack[1]; + int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; + int retcode; + if (obj == Py_None) { + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, + PyBUF_RECORDS, 2, + &__Pyx_TypeInfo_double, stack, + &result, obj); + if (unlikely(retcode == -1)) + goto __pyx_fail; + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; +} + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* ModuleImport */ + #ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE 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 CYTHON_COMPILING_IN_CPYTHON && (__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 + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +#endif + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return __Pyx_NewRef(x); + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx new file mode 100644 index 00000000000..9d21fd0956e --- /dev/null +++ b/Orange/distance/_distance.pyx @@ -0,0 +1,357 @@ +#cython: embedsignature=True +#cython: infer_types=True +#cython: cdivision=True +#cython: boundscheck=False +#cython: wraparound=False + +import numpy as np +cimport numpy as np + +cdef extern from "numpy/npy_math.h": + bint npy_isnan(double x) nogil + +cdef extern from "math.h": + double fabs(double x) nogil + double sqrt(double x) nogil + + +# This function is unused, but kept here for any future use +cdef _check_division_by_zero(double[:, :] x, double[:] dividers): + cdef int col + for col in range(dividers.shape[0]): + if dividers[col] == 0 and not x[:, col].isnan().all(): + raise ValueError("cannot normalize: the data has no variance") + + +cdef _lower_to_symmetric(double [:, :] distances): + cdef int row1, row2 + for row1 in range(distances.shape[0]): + for row2 in range(row1): + distances[row2, row1] = distances[row1, row2] + + +def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + fit_params): + cdef: + double [:] vars = fit_params["vars"] + double [:] means = fit_params["means"] + double [:, :] dist_missing = fit_params["dist_missing"] + double [:] dist_missing2 = fit_params["dist_missing2"] + char normalize = fit_params["normalize"] + + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + int ival1, ival2 + double [:, :] distances + char same = x1 is x2 + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + assert n_cols == x2.shape[1] == len(vars) == len(means) \ + == len(dist_missing) == len(dist_missing2) + distances = np.zeros((n_rows1, n_rows2), dtype=float) + + with nogil: + for row1 in range(n_rows1): + for row2 in range(row1 if same else n_rows2): + d = 0 + for col in range(n_cols): + if vars[col] == -2: + continue + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1) and npy_isnan(val2): + d += dist_missing2[col] + elif vars[col] == -1: + ival1, ival2 = int(val1), int(val2) + if npy_isnan(val1): + d += dist_missing[col, ival2] + elif npy_isnan(val2): + d += dist_missing[col, ival1] + elif ival1 != ival2: + d += 1 + elif normalize: + if npy_isnan(val1): + d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + elif npy_isnan(val2): + d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + else: + d += ((val1 - val2) ** 2 / vars[col]) / 2 + else: + if npy_isnan(val1): + d += (val2 - means[col]) ** 2 + vars[col] + elif npy_isnan(val2): + d += (val1 - means[col]) ** 2 + vars[col] + else: + d += (val1 - val2) ** 2 + distances[row1, row2] = d + if same: + _lower_to_symmetric(distances) + return np.sqrt(distances) + + +def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + cdef: + double [:] means = fit_params["means"] + double [:] vars = fit_params["vars"] + char normalize = fit_params["normalize"] + + int n_rows, n_cols, col1, col2, row + double val1, val2, d + double [:, :] distances + + n_rows, n_cols = x.shape[0], x.shape[1] + distances = np.zeros((n_cols, n_cols), dtype=float) + with nogil: + for col1 in range(n_cols): + for col2 in range(col1): + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if normalize: + val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + if npy_isnan(val1): + if npy_isnan(val2): + d += 1 + else: + d += val2 ** 2 + 0.5 + elif npy_isnan(val2): + d += val1 ** 2 + 0.5 + else: + d += (val1 - val2) ** 2 + else: + if npy_isnan(val1): + if npy_isnan(val2): + d += vars[col1] + vars[col2] \ + + (means[col1] - means[col2]) ** 2 + else: + d += (val2 - means[col1]) ** 2 + vars[col1] + elif npy_isnan(val2): + d += (val1 - means[col2]) ** 2 + vars[col2] + else: + d += (val1 - val2) ** 2 + distances[col1, col2] = distances[col2, col1] = d + return np.sqrt(distances) + + +def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + fit_params): + cdef: + double [:] medians = fit_params["medians"] + double [:] mads = fit_params["mads"] + double [:, :] dist_missing = fit_params["dist_missing"] + double [:] dist_missing2 = fit_params["dist_missing2"] + char normalize = fit_params["normalize"] + char same = x1 is x2 + + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + int ival1, ival2 + double [:, :] distances + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + == len(dist_missing) == len(dist_missing2) + + distances = np.zeros((n_rows1, n_rows2), dtype=float) + for row1 in range(n_rows1): + for row2 in range(row1 if same else n_rows2): + d = 0 + for col in range(n_cols): + if mads[col] == -2: + continue + + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1) and npy_isnan(val2): + d += dist_missing2[col] + elif mads[col] == -1: + ival1, ival2 = int(val1), int(val2) + if npy_isnan(val1): + d += dist_missing[col, ival2] + elif npy_isnan(val2): + d += dist_missing[col, ival1] + elif ival1 != ival2: + d += 1 + elif normalize: + if npy_isnan(val1): + d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + elif npy_isnan(val2): + d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + else: + d += fabs(val1 - val2) / mads[col] / 2 + else: + if npy_isnan(val1): + d += fabs(val2 - medians[col]) + mads[col] + elif npy_isnan(val2): + d += fabs(val1 - medians[col]) + mads[col] + else: + d += fabs(val1 - val2) + + distances[row1, row2] = d + + if same: + _lower_to_symmetric(distances) + return distances + + +def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + cdef: + double [:] medians = fit_params["medians"] + double [:] mads = fit_params["mads"] + char normalize = fit_params["normalize"] + + int n_rows, n_cols, col1, col2, row + double val1, val2, d + double [:, :] distances + + n_rows, n_cols = x.shape[0], x.shape[1] + distances = np.zeros((n_cols, n_cols), dtype=float) + for col1 in range(n_cols): + for col2 in range(col1): + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if normalize: + val1 = (val1 - medians[col1]) / (2 * mads[col1]) + val2 = (val2 - medians[col2]) / (2 * mads[col2]) + if npy_isnan(val1): + if npy_isnan(val2): + d += 1 + else: + d += fabs(val2) + 0.5 + elif npy_isnan(val2): + d += fabs(val1) + 0.5 + else: + d += fabs(val1 - val2) + else: + if npy_isnan(val1): + if npy_isnan(val2): + d += mads[col1] + mads[col2] \ + + fabs(medians[col1] - medians[col2]) + else: + d += fabs(val2 - medians[col1]) + mads[col1] + elif npy_isnan(val2): + d += fabs(val1 - medians[col2]) + mads[col2] + else: + d += fabs(val1 - val2) + distances[col1, col2] = distances[col2, col1] = d + return distances + + +def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): + cdef: + int row, n_cols, nonzeros, nonnans + double val + double [:] ps + + n_cols = x.shape[1] + ps = np.empty(n_cols, dtype=np.double) + for col in range(n_cols): + nonzeros = nonnans = 0 + for row in range(len(x)): + val = x[row, col] + if not npy_isnan(val): + nonnans += 1 + if val != 0: + nonzeros += 1 + ps[col] = float(nonzeros) / nonnans + return {"ps": ps} + + +def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + fit_params): + cdef: + double [:] ps = fit_params["ps"] + char same = x1 is x2 + + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, intersection, union + int ival1, ival2 + double [:, :] distances + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + assert n_cols == x2.shape[1] == ps.shape[0] + + distances = np.ones((n_rows1, n_rows2), dtype=float) + for row1 in range(n_rows1): + for row2 in range(row1 if same else n_rows2): + intersection = union = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x1[row2, col] + if npy_isnan(val1): + if npy_isnan(val2): + intersection += ps[col] ** 2 + union += 1 - (1 - ps[col]) ** 2 + elif val2 != 0: + intersection += ps[col] + union += 1 + else: + union += ps[col] + elif npy_isnan(val2): + if val1 != 0: + intersection += ps[col] + union += 1 + else: + union += ps[col] + else: + if val1 != 0 and val2 != 0: + intersection += 1 + if val1 != 0 or val2 != 0: + union += 1 + if union != 0: + distances[row1, row2] = 1 - intersection / union + + if same: + _lower_to_symmetric(distances) + return distances + + +def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + cdef: + double [:] ps = fit_params["ps"] + + int n_rows, n_cols, col1, col2, row + double val1, val2 + int in_both, in_one, in1_unk2, unk1_in2, unk1_unk2, unk1_not2, not1_unk2 + double [:, :] distances + + n_rows, n_cols = x.shape[0], x.shape[1] + distances = np.ones((n_cols, n_cols), dtype=float) + for col1 in range(n_cols): + for col2 in range(col1): + in_both = in_one = 0 + in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if npy_isnan(val1): + if npy_isnan(val2): + unk1_unk2 += 1 + elif val2 != 0: + unk1_in2 += 1 + else: + unk1_not2 += 1 + elif npy_isnan(val2): + if val1 != 0: + in1_unk2 += 1 + else: + not1_unk2 += 1 + else: + if val1 != 0 and val2 != 0: + in_both += 1 + elif val1 != 0 or val2 != 0: + in_one += 1 + distances[col1, col2] = distances[col2, col1] = \ + 1 - float(in_both + + ps[col1] * unk1_in2 + + + ps[col2] * in1_unk2 + + + ps[col1] * ps[col2] * unk1_unk2) / \ + (in_both + in_one + unk1_in2 + in1_unk2 + + + ps[col1] * unk1_not2 + + ps[col2] * not1_unk2 + + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + return distances diff --git a/Orange/distance/distances.md b/Orange/distance/distances.md new file mode 100644 index 00000000000..a298f46bd92 --- /dev/null +++ b/Orange/distance/distances.md @@ -0,0 +1,158 @@ +# Computation of distances in Orange 3 + +This document describes and justifies how Orange 3 computes distances between data rows or columns from the data that can include discrete (nominal) and numeric features with missing values. + +The aim of normalization is to bring all numeric features onto the same scale and on the same scale as discrete features. The meaning of *the same scale* is rather arbitrary. We gauge the normalization so that missing values have the same effect for all features and their types, and so that Euclidean and cosine distances are nicely related. + +For missing values, we compute the expected difference given the probability distribution of the feature that is estimated from the data. + +Two nominal values are treated as same or different, that is, the difference between them is 0 and 1. + +Difference between values of two distinct nominal features does not make sense, so Orange reports an error when the user tries to compute column-wise distance in data with some non-numeric features. + +## Euclidean distance + +#### Normalization of numeric features + +Orange 2 used to normalize by subtracting the minimum and dividing by the span (the difference between the maximum and the minimum) to bring the range of differences into interval $[0, 1]$. This however did not work since the data on which the distances were computed could include more extreme values than the training data. + +Normalization in Orange 3 is based on mean and variance due to other desired effects described below. A value $x$ is normalized as + +$$ x' = \frac{x - \mu}{\sqrt{2\sigma^2}},$$ + +where $\mu$ and $\sigma^2$ are the mean and the variance of that feature (e.g. estimated accross the column). + +Normalized values thus have a mean of $\mu'=0$ and a variance of $\sigma'^2 = 1/2$. + +#### Missing values of numeric features + +If one value (denoted by $v$) is known and one missing, the expected difference along this dimension is + +$$\int_{-\infty}^{\infty}(v - x)^2p(x)dx = \\ +v^2\int_{-\infty}^{\infty}p(x)dx- 2v\int_{-\infty}^{\infty}xp(x) + \int_{-\infty}^{\infty}x^2p(x) = \\ +v^2 - 2v\mu + (\sigma^2 + \mu^2) = \\ +(v - \mu)^2 + \sigma^2.$$ + +If both values are unknown and we compute the difference between rows so that both values come from the same distirbutions, we have + +$$\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}(x - y)^2p(x)p(y)dxdy = \\ + \int_{-\infty}^{\infty}\int_{-\infty}^{\infty}x^2p(x)p(y)dxdy + + \int_{-\infty}^{\infty}\int_{-\infty}^{\infty}y^2p(x)p(y)dxdy + - 2\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}xyp(x)p(y)dxdy = \\ + (\sigma^2 + \mu^2) + (\sigma^2 + \mu^2) - 2\int_{-\infty}^{\infty}xp(x)dx\int_{-\infty}^{\infty}yp(y)dxdy = \\ + (\sigma^2 + \mu^2) + (\sigma^2 + \mu^2) - 2\mu\mu = \\ + 2\sigma^2.$$ + +When computing the difference between columns, the derivation is similar except that the two distributions are not the same. For one missing value we get + +$$(v - \mu_x)^2 + \sigma_x^2$$ + +where $\mu_x$ and $\sigma_x$ correspond to the distribution of the unknown value. For two missing values, we get + +$$\sigma_x^2 + \sigma_y^2 + \mu_x^2 + \mu_y^2 - 2\mu_x\mu_y = \\ +\sigma_x^2 + \sigma_y^2 + (\mu_x - \mu_y)^ 2.$$ + +For normalized data, the difference between $v$ and unknown value is $(v' - \mu)^2 + \sigma^2 = v'^2 + 1/2$. The difference between two missing values is $2\sigma^2 = 1$ (or $\sigma_x^2 + \sigma_y^2 + (\mu_x - \mu_y)^2 = 1$). + +#### Missing values of discrete features + +The difference between a known and a missing value is + +$$\sum_x \mbox{I}_{v\ne x}^2p(x) = 1 - p(x).$$ + +The difference between two missing values is + +$$\sum_x\sum_y \mbox{I}_{y\ne x}^2p(x)p(y) = 1 - \sum_x p(x)^2.$$ + +This is the Gini index. Also, if the number of values goes to infinity and the distribution towards the uniform, the difference goes towards 1, which brings it, in some sense, to the same scale as continuous features. + +This case assumes that $x$ and $y$ come from the same distribution. The case when these are missing values of two distinct discrete features is not covered since Orange does not support such distances (see the introduction). + +## Manhattan distance + +The derivation here may be more difficult, so we do it by analogy with Euclidean distances and hope for the best. + +We use the median ($m$) and median of absolute distances to the median (mad) ($a$) instead of the mean and the variance. + +Normalization of numeric features: $x' = (x - m)\,/\,(2a)$ + +#### Missing values of numeric features + +**Between a known and a missing**: $|v - m| + a.$ + +**Between two unknowns**: $2a$ (same features), $a_x + a_y$ (different features). + +**For normalized data**: $|v'| + 1/2$ (one unknown), $1$ (both unknown). + +#### Missing values of discrete features + +Same as for Euclidean because $I_{v\ne x}^2 = I_{v\ne x}$. + + +## Cosine distance + +Consider that Euclidean distance $\sum_i(x_i - y_i)^2$ equals $\sum_i{x_i^2} + \sum_i{y_i^2} - 2\sum_i{x_iy_i}$. Now assume that $x$ and $y$ are normalized as described in the computation of the Euclidean distance, except that when computing the distances across the rows, the normalization is also done **across the rows**, not columns (features). In this case, $\sum_i{x_i^2} = \sum_i{y_i^2} = 1 / 2$. Thus with proper normalization, cosine distance can be computed using the same formulae for missing values as the Euclidean distance, and then converted by + +$$Cosine(x, y) = +\cos\frac{\sum_i x_iy_i}{\sqrt{\sum_i x_i^2}\sqrt{\sum_i y_i^2}} = \\ \cos\frac{1/2\left(\sum_i{x_i^2} + \sum_i{y_i^2} - \sum_i(x_i - y_i)^2\right)}{\sqrt{\sum_i x_i^2}\sqrt{\sum_i y_i^2}} = \\ +\cos\frac{1/2\left(1/2 + 1/2 - \sum_i(x_i - y_i)^2\right)}{\sqrt{1/2}\sqrt{1/2}} = \\ +\cos(1 - Eucl(x, y))$$ + + +## Jaccard distance + +Let $p(A_i)$ be the probability (computed from the training data) that a random data instance belongs to set $A_i$, i.e., have a non-zero value for feature $A_i$. + +### Distances between rows (instances) + +Let $M$ and $N$ be two data instances. $M$ and $N$ can belong to $A_i$ (or not). The Jaccard similarity between $M$ and $N$ is the number of the common sets to which $M$ and $N$ belong, divided by the number of sets with either $M$ or $N$ (or both). + +Let $\mbox{I}_M$ be 1 if $M\in A_i$ and 0 otherwise. Similarly, $\mbox{I}_{M'}$ will indicate that $M\not\in A_i$ and $\mbox{I}_{M?}$ will indicate that it is unknown whether $M$ belongs to $A_i$ or not. We will also use conjuctions and disjunctions by adding more indices to $\mbox{I}$; e.g. $\mbox{I}_{M\wedge N'}$ indicates that $M$ belongs to $A_i$ and $N$ does not. $A_i$ is omitted for clarity as it can be deduced from the context. + +$$Jaccard(M, N) = \frac{\sum_i\mbox{I}_{M\wedge N}}{\sum_i\mbox{I}_{M\vee N}}$$ + +Consider that $\mbox{I}_{M\wedge N} = \mbox{I}_M \mbox{I}_N$ and $\mbox{I}_{M\vee N} = \max(\mbox{I}_M, \mbox{I}_N)$. If the data whether $M\in A_i$ or $N\in A_i$ is missing, we replace indicator function with the probability. In the denominator we add a few terms to $\mbox{I}_{M\wedge N}$ + +$$\mbox{I}_{M\wedge N} + + p(A_i)\mbox{I}_{M\wedge N?} + + p(A_i)\mbox{I}_{M?\wedge N} + + p(A_i)^2\mbox{I}_{M?\wedge N?},$$ + +and in the nominator we get + +$$\mbox{I}_{M\vee N} + p(A_i)\mbox{I}_{M'\wedge N?} + p(A_i)\mbox{I}_{M?\wedge N'} + \left(1 - (1 - p(A_i)^2\right)\mbox{I}_{I?\wedge J?}$$ + +Note that the denominator counts cases $\mbox{I}_{M'\wedge N?}$ and not $\mbox{I}_{N?}$, since those for which $M\in A_i$ are already covered in $\mbox{I}_{M\vee N}$. The last term refers to the probability that at least one (that is, not none) of the two instances is in $A_i$. + +### Distances between columns + +$\mbox{I}_{i}$ will now denote that a data instance $M$ belongs to $A_i$, $\mbox{I}_{i'}$ will denote it does not, and $\mbox{I}_{i?}$ will denote that it is unknown whether $M$ belongs to $A_i$. + +Without considering missing data, Jaccard index between two columns is + +$$Jaccard(A_i, A_j) = \frac{\sum_M\mbox{I}_{i\wedge j}}{\sum_M\mbox{I}_{i\vee j}}$$ + +By the same reasoning as above, the denominator becomes + +$$\mbox{I}_{i\wedge j} + + p(A_j)\mbox{I}_{i\wedge j?} + + p(A_i)\mbox{I}_{i?\wedge j} + + p(A_i)p(A_j)\mbox{I}_{i?\wedge j?},$$ + +and the nominator is + +$$\mbox{I}_{i\vee j} + p(A_j)\mbox{I}_{i'\wedge j?} + p(A_i)\mbox{I}_{i?\wedge j'} + \left(1 - [1 - p(A_i)][1 - p(A_j)]\right)\mbox{I}_{I?\wedge J?}.$$ + +The sums runs over instances, $M$, so the actual implementation can work by counting the cases and multipying by probabilities at the end. Let $N_c$ represent the number of cases that match condition $c$, i.e. $N_c = \sum_M\mbox{I}_c$. Then + +$$Jaccard(A_i, A_j) = \frac{ + N_{i\wedge j} + + p(A_j)N_{i\wedge j?} + + p(A_i)N_{i?\wedge j} + + p(A_i) p(A_j)N_{i?\wedge j?} + }{ + N_{i\vee j} + + p(A_j)N_{i'\wedge j?} + + p(A_i)N_{i?\wedge j'} + + \left(1 - [1 - p(A_i)][1 - p(A_j]\right)N_{i?\wedge j?} + }$$ diff --git a/Orange/distance/setup.py b/Orange/distance/setup.py new file mode 100644 index 00000000000..7ea061bd6b7 --- /dev/null +++ b/Orange/distance/setup.py @@ -0,0 +1,22 @@ +import os + +import numpy + + +def configuration(parent_package='', top_path=None): + from numpy.distutils.misc_util import Configuration + + libraries = [] + if os.name == 'posix': + libraries.append('m') + + config = Configuration('distance', parent_package, top_path) + config.add_extension('_distance', + sources=['_distance.c'], + include_dirs=[numpy.get_include()], + libraries=libraries) + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) diff --git a/Orange/distance/tests/test_distance.py b/Orange/distance/tests/test_distance.py new file mode 100644 index 00000000000..b485dd23f31 --- /dev/null +++ b/Orange/distance/tests/test_distance.py @@ -0,0 +1,754 @@ +import unittest + +import numpy as np + +from Orange.data import ContinuousVariable, DiscreteVariable, Domain, Table +from Orange import distance + + +class CommonTests: + """Tests applicable to all distance measures""" + + def test_no_data(self): + """distances return zero-dimensional matrices when no data""" + n = len(self.data) + np.testing.assert_almost_equal( + self.Distance(Table(self.domain)), + np.zeros((0, 0))) + np.testing.assert_almost_equal( + self.Distance(self.data, Table(self.domain)), + np.zeros((n, 0))) + np.testing.assert_almost_equal( + self.Distance(Table(self.domain), self.data), + np.zeros((0, n))) + + +class CommonFittedTests(CommonTests): + """Tests applicable to all distances with fitting""" + def test_mismatching_attributes(self): + """distances can't be computed if fit from other attributes""" + def new_table(): + return Table.from_list(Domain([ContinuousVariable("a")]), [[1]]) + + table1 = new_table() + model = self.Distance().fit(table1) + self.assertRaises(ValueError, model, new_table()) + self.assertRaises(ValueError, model, table1, new_table()) + self.assertRaises(ValueError, model, new_table(), table1) + + +class CommonNormalizedTests(CommonFittedTests): + """Tests applicable to distances the have normalization""" + + def test_zero_variance(self): + """zero-variance columns have no effect on row distance""" + assert_almost_equal = np.testing.assert_almost_equal + normalized = self.Distance(axis=1, normalize=True) + nonnormalized = self.Distance(axis=1, normalize=False) + + def is_same(d1, d2, fit1=None, fit2=None): + if fit1 is None: + fit1 = d1 + if fit2 is None: + fit2 = d2 + assert_almost_equal(normalized.fit(fit1)(d1), + normalized.fit(fit2)(d2)) + assert_almost_equal(nonnormalized.fit(fit1)(d1), + nonnormalized.fit(fit2)(d2)) + + data = self.cont_data + n = len(data) + X = data.X + domain = Domain(data.domain.attributes + (ContinuousVariable("d"),)) + data_const = Table(domain, np.hstack((X, np.ones((n, 1))))) + data_nan = Table(domain, np.hstack((X, np.full((n, 1), np.nan)))) + data_nan_1 = Table(domain, np.hstack((X, np.full((n, 1), np.nan)))) + data_nan_1.X[0, -1] = 1 + is_same(data, data_const) + is_same(data, data_nan) + is_same(data, data_nan_1) + + # Test whether it's possible to fit with singular data and use the + # parameters on data where the same column is defined + is_same(data_nan, data_const, data_const) + is_same(data_const, data_const, data_nan) + + self.assertRaises(ValueError, self.Distance, data_const, axis=0) + self.assertRaises(ValueError, self.Distance, data_nan, axis=0) + self.assertRaises(ValueError, self.Distance, data_nan_1, axis=0) + + def test_mixed_cols(self): + """distance over columns raises exception for discrete columns""" + self.assertRaises(ValueError, self.Distance, self.mixed_data, axis=0) + self.assertRaises(ValueError, + self.Distance(axis=0).fit, self.mixed_data) + + +class FittedDistanceTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.attributes = ( + ContinuousVariable("c1"), + ContinuousVariable("c2"), + ContinuousVariable("c3"), + DiscreteVariable("d1", values=["a", "b"]), + DiscreteVariable("d2", values=["a", "b", "c", "d"]), + DiscreteVariable("d3", values=["a", "b", "c"])) + cls.domain = Domain(cls.attributes) + cls.cont_domain = Domain(cls.attributes[:3]) + cls.disc_domain = Domain(cls.attributes[3:]) + + def setUp(self): + self.cont_data = Table.from_list( + self.cont_domain, + [[1, 3, 2], + [-1, 5, 0], + [1, 1, 1], + [7, 2, 3]]) + + self.cont_data2 = Table.from_list( + self.cont_domain, + [[2, 1, 3], + [1, 2, 2]] + ) + + self.disc_data = Table.from_list( + self.disc_domain, + [[0, 0, 0], + [0, 1, 1], + [1, 3, 1]] + ) + + self.disc_data4 = Table.from_list( + self.disc_domain, + [[0, 0, 0], + [0, 1, 1], + [0, 1, 1], + [1, 3, 1]] + ) + + self.mixed_data = self.data = Table.from_numpy( + self.domain, np.hstack((self.cont_data.X[:3], self.disc_data.X))) + + + +# Correct results in these tests were computed manually or with Excel; +# these are not regression tests +class EuclideanDistanceTest(FittedDistanceTest, CommonNormalizedTests): + Distance = distance.Euclidean + + def test_euclidean_disc(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.disc_data + + model = distance.Euclidean().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 5/9, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.sqrt(np.array([[0, 2, 3], + [2, 0, 2], + [3, 2, 0]]))) + + data.X[1, 0] = np.nan + model = distance.Euclidean().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/2, 1/2, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 2/4, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.sqrt(np.array([[0, 2.5, 3], + [2.5, 0, 1.5], + [3, 1.5, 0]]))) + + data.X[0, 0] = np.nan + model = distance.Euclidean().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1, 0, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 1, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.sqrt(np.array([[0, 2, 2], + [2, 0, 1], + [2, 1, 0]]))) + + data = self.disc_data4 + data.X[:2, 0] = np.nan + model = distance.Euclidean().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/2, 1/2, 1, 1], + [3/4, 2/4, 1, 3/4], + [3/4, 1/4, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 2/4, 1 - 6/16, 1 - 10/16])) + assert_almost_equal(dist, + np.sqrt(np.array([[0, 2.5, 2.5, 2.5], + [2.5, 0, 0.5, 1.5], + [2.5, 0.5, 0, 2], + [2.5, 1.5, 2, 0], + ]))) + + def test_euclidean_cont(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Euclidean(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.sqrt(np.array([[0, 12, 5, 38], + [12, 0, 21, 82], + [5, 21, 0, 41], + [38, 82, 41, 0]]))) + + data.X[1, 0] = np.nan + dist = distance.Euclidean(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 4.472135955, 2.236067977, 6.164414003], + [4.472135955, 0, 5.385164807, 6.480740698], + [2.236067977, 5.385164807, 0, 6.403124237], + [6.164414003, 6.480740698, 6.403124237, 0]])) + + data.X[0, 0] = np.nan + dist = distance.Euclidean(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 5.099019514, 4.795831523, 4.472135955], + [5.099019514, 0, 5.916079783, 6], + [4.795831523, 5.916079783, 0, 6.403124237], + [4.472135955, 6, 6.403124237, 0]])) + + def test_euclidean_cont_normalized(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + model = distance.Euclidean(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["means"], np.array([2, 2.75, 1.5])) + assert_almost_equal(params["vars"], np.array([9, 2.1875, 1.25])) + assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) + assert_almost_equal(params["dist_missing2"], np.ones(3)) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 1.654239383, 1.146423008, 1.621286967], + [1.654239383, 0, 2.068662631, 3.035242727], + [1.146423008, 2.068662631, 0, 1.956673562], + [1.621286967, 3.035242727, 1.956673562, 0]])) + + dist = distance.Euclidean(data, axis=1, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 1.654239383, 1.146423008, 1.621286967], + [1.654239383, 0, 2.068662631, 3.035242727], + [1.146423008, 2.068662631, 0, 1.956673562], + [1.621286967, 3.035242727, 1.956673562, 0]])) + + data.X[1, 0] = np.nan + model = distance.Euclidean(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["means"], np.array([3, 2.75, 1.5])) + assert_almost_equal(params["vars"], np.array([8, 2.1875, 1.25])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 1.806733438, 1.146423008, 1.696635326], + [1.806733438, 0, 2.192519751, 2.675283697], + [1.146423008, 2.192519751, 0, 2.019547333], + [1.696635326, 2.675283697, 2.019547333, 0]])) + + data.X[0, 0] = np.nan + model = distance.Euclidean(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["means"], np.array([4, 2.75, 1.5])) + assert_almost_equal(params["vars"], np.array([9, 2.1875, 1.25])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 1.874642823, 1.521277659, 1.276154939], + [1.874642823, 0, 2.248809209, 2.580143961], + [1.521277659, 2.248809209, 0, 1.956673562], + [1.276154939, 2.580143961, 1.956673562, 0]])) + + def test_euclidean_cols(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Euclidean(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 8.062257748, 4.242640687], + [8.062257748, 0, 5.196152423], + [4.242640687, 5.196152423, 0]])) + + data.X[1, 1] = np.nan + dist = distance.Euclidean(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 6.218252702, 4.242640687], + [6.218252702, 0, 2.581988897], + [4.242640687, 2.581988897, 0]])) + + data.X[1, 0] = np.nan + dist = distance.Euclidean(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 6.218252702, 5.830951895], + [6.218252702, 0, 2.581988897], + [5.830951895, 2.581988897, 0]])) + + def test_euclidean_cols_normalized(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Euclidean(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 2.455273959, 0.649839392], + [2.455273959, 0, 2.473176308], + [0.649839392, 2.473176308, 0]])) + + data.X[1, 1] = np.nan + dist = distance.Euclidean(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 2, 0.649839392], + [2, 0, 1.704275472], + [0.649839392, 1.704275472, 0]])) + + data.X[1, 0] = np.nan + dist = distance.Euclidean(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 2, 1.450046001], + [2, 0, 1.704275472], + [1.450046001, 1.704275472, 0]])) + + def test_euclidean_mixed(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.mixed_data + + model = distance.Euclidean(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["means"], + np.array([1/3, 3, 1, 0, 0, 0])) + assert_almost_equal(params["vars"], + np.array([8/9, 8/3, 2/3, -1, -1, -1])) + assert_almost_equal(params["dist_missing"], + np.array([[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 2.828427125, 2.121320344], + [2.828427125, 0, 2.828427125], + [2.121320344, 2.828427125, 0]])) + + def test_two_tables(self): + assert_almost_equal = np.testing.assert_almost_equal + + dist = distance.Euclidean(self.cont_data, self.cont_data2, + normalize=True) + assert_almost_equal( + dist, + np.array([[1.17040218, 0.47809144], + [2.78516478, 1.96961039], + [1.28668394, 0.79282497], + [1.27179413, 1.54919334]])) + + model = distance.Euclidean(normalize=True).fit(self.cont_data) + dist = model(self.cont_data, self.cont_data2) + assert_almost_equal( + dist, + np.array([[1.17040218, 0.47809144], + [2.78516478, 1.96961039], + [1.28668394, 0.79282497], + [1.27179413, 1.54919334]])) + + dist = model(self.cont_data2) + assert_almost_equal( + dist, + np.array([[0, 0.827119692], [0.827119692, 0]])) + + +class ManhattanDistanceTest(FittedDistanceTest, CommonNormalizedTests): + Distance = distance.Euclidean + + # The data used for testing Euclidean distances unfortunately yields + # mads = 1, so we change it a bit + def setUp(self): + super().setUp() + self.cont_data = Table.from_list( + self.cont_domain, + [[1, 3, 2], + [-1, 6, 0], + [2, 7, 1], + [7, 1, 3]]) + + def test_manhattan_no_data(self): + np.testing.assert_almost_equal( + distance.Manhattan(Table(self.domain)), + np.zeros((0, 0))) + np.testing.assert_almost_equal( + distance.Manhattan(self.mixed_data, Table(self.domain)), + np.zeros((3, 0))) + np.testing.assert_almost_equal( + distance.Manhattan(Table(self.domain), self.mixed_data), + np.zeros((0, 3))) + self.assertRaises( + ValueError, + distance.Manhattan, Table(self.cont_domain), axis=0) + + def test_manhattan_disc(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.disc_data + + model = distance.Manhattan().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 5/9, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.array([[0, 2, 3], + [2, 0, 2], + [3, 2, 0]])) + + data.X[1, 0] = np.nan + model = distance.Manhattan().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/2, 1/2, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 2/4, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.array([[0, 2.5, 3], + [2.5, 0, 1.5], + [3, 1.5, 0]])) + + data.X[0, 0] = np.nan + model = distance.Manhattan().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1, 0, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 1, 1 - 3/9, 1 - 5/9])) + assert_almost_equal(dist, + np.array([[0, 2, 2], + [2, 0, 1], + [2, 1, 0]])) + + data = self.disc_data4 + data.X[:2, 0] = np.nan + model = distance.Manhattan().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["dist_missing"], + np.array([[1/2, 1/2, 1, 1], + [3/4, 2/4, 1, 3/4], + [3/4, 1/4, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1 - 2/4, 1 - 6/16, 1 - 10/16])) + assert_almost_equal(dist, + np.array([[0, 2.5, 2.5, 2.5], + [2.5, 0, 0.5, 1.5], + [2.5, 0.5, 0, 2], + [2.5, 1.5, 2, 0]])) + + def test_manhattan_cont(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Manhattan(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 7, 6, 9], + [7, 0, 5, 16], + [6, 5, 0, 13], + [9, 16, 13, 0]])) + + data.X[1, 0] = np.nan + dist = distance.Manhattan(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 7, 6, 9], + [7, 0, 3, 14], + [6, 3, 0, 13], + [9, 14, 13, 0]])) + + data.X[0, 0] = np.nan + dist = distance.Manhattan(data, axis=1, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 10, 10, 8], + [10, 0, 7, 13], + [10, 7, 0, 13], + [8, 13, 13, 0]])) + + def test_manhattan_cont_normalized(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + model = distance.Manhattan(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["medians"], np.array([1.5, 4.5, 1.5])) + assert_almost_equal(params["mads"], np.array([1.5, 2, 1])) + assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) + assert_almost_equal(params["dist_missing2"], np.ones(3)) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 2.416666667, 1.833333333, 3], + [2.416666667, 0, 1.75, 5.416666667], + [1.833333333, 1.75, 0, 4.166666667], + [3, 5.416666667, 4.166666667, 0]])) + + dist = distance.Manhattan(data, axis=1, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 2.416666667, 1.833333333, 3], + [2.416666667, 0, 1.75, 5.416666667], + [1.833333333, 1.75, 0, 4.166666667], + [3, 5.416666667, 4.166666667, 0]])) + + data.X[1, 0] = np.nan + model = distance.Manhattan(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["medians"], np.array([2, 4.5, 1.5])) + assert_almost_equal(params["mads"], np.array([1, 2, 1])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 2.75, 2, 4], + [2.75, 0, 1.25, 5.75], + [2, 1.25, 0, 5], + [4, 5.75, 5, 0]])) + + data.X[0, 0] = np.nan + model = distance.Manhattan(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["medians"], np.array([4.5, 4.5, 1.5])) + assert_almost_equal(params["mads"], np.array([2.5, 2, 1])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 2.75, 2.5, 2], + [2.75, 0, 1.75, 3.75], + [2.5, 1.75, 0, 3.5], + [2, 3.75, 3.5, 0]])) + + def test_manhattan_cols(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Manhattan(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 20, 7], + [20, 0, 15], + [7, 15, 0]])) + + data.X[1, 1] = np.nan + dist = distance.Manhattan(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 19, 7], + [19, 0, 14], + [7, 14, 0]])) + + data.X[1, 0] = np.nan + dist = distance.Manhattan(data, axis=0, normalize=False) + assert_almost_equal( + dist, + np.array([[0, 17, 9], + [17, 0, 14], + [9, 14, 0]])) + + + def test_manhattan_cols_normalized(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Manhattan(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 4.5833333, 2], + [4.5833333, 0, 4.25], + [2, 4.25, 0]])) + + data.X[1, 1] = np.nan + dist = distance.Manhattan(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 4.6666667, 2], + [4.6666667, 0, 4], + [2, 4, 0]])) + + data.X[1, 0] = np.nan + dist = distance.Manhattan(data, axis=0, normalize=True) + assert_almost_equal( + dist, + np.array([[0, 5.5, 4], + [5.5, 0, 4], + [4, 4, 0]])) + + def test_manhattan_mixed(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.mixed_data + + data.X[2, 0] = 2 # prevent mads[0] = 0 + model = distance.Manhattan(axis=1, normalize=True).fit(data) + params = model.fit_params + assert_almost_equal(params["medians"], + np.array([1, 3, 1, 0, 0, 0])) + assert_almost_equal(params["mads"], + np.array([1, 2, 1, -1, -1, -1])) + assert_almost_equal(params["dist_missing"], + np.array([[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ])) + assert_almost_equal(params["dist_missing2"], + np.array([1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9])) + dist = model(data) + assert_almost_equal( + dist, + np.array([[0, 4.5, 4.5], + [4.5, 0, 5], + [4.5, 5, 0]])) + + def test_two_tables(self): + assert_almost_equal = np.testing.assert_almost_equal + + dist = distance.Manhattan(self.cont_data, self.cont_data2, + normalize=True) + assert_almost_equal( + dist, + np.array([[1.3333333, 0.25], + [3.75, 2.6666667], + [2.5, 2.0833333], + [1.6666667, 2.75]])) + + model = distance.Manhattan(normalize=True).fit(self.cont_data) + dist = model(self.cont_data, self.cont_data2) + assert_almost_equal( + dist, + np.array([[1.3333333, 0.25], + [3.75, 2.6666667], + [2.5, 2.0833333], + [1.6666667, 2.75]])) + + dist = model(self.cont_data2) + assert_almost_equal( + dist, + np.array([[0, 1.083333333], [1.083333333, 0]])) + + def test_manhattan_mixed_cols(self): + self.assertRaises(ValueError, + distance.Manhattan, self.mixed_data, axis=0) + self.assertRaises(ValueError, + distance.Manhattan(axis=0).fit, self.mixed_data) + + +class JaccardDistanceTest(unittest.TestCase, CommonFittedTests): + Distance = distance.Jaccard + + def setUp(self): + self.domain = Domain([DiscreteVariable(c) for c in "abc"]) + self.data = Table( + self.domain, + [[0, 1, 1], + [1, 1, 1], + [1, 0, 1], + [1, 0, 0]]) + + def test_jaccard_rows(self): + assert_almost_equal = np.testing.assert_almost_equal + + model = distance.Jaccard().fit(self.data) + assert_almost_equal(model.fit_params["ps"], np.array([0.75, 0.5, 0.75])) + assert_almost_equal( + model(self.data), + 1 - np.array([[0, 2/3, 1/3, 0], + [2/3, 0, 2/3, 1/3], + [1/3, 2/3, 0, 1/2], + [0, 1/3, 1/2, 0]])) + + X = self.data.X + X[1, 0] = X[2, 0] = X[3, 1] = np.nan + model = distance.Jaccard().fit(self.data) + assert_almost_equal(model.fit_params["ps"], np.array([0.5, 2/3, 0.75])) + assert_almost_equal( + model(self.data), + 1 - np.array([[ 0, 2 / 2.5, 1 / 2.5, 2/3 / 3], + [2 / 2.5, 0, 1.25 / 2.75, (1/2+2/3) / 3], + [1 / 2.5, 1.25 / 2.75, 0, 0.5 / (2+2/3)], + [2/3 / 3, (1/2+2/3) / 3, 0.5 / (2+2/3), 0]])) + + def test_jaccard_cols(self): + assert_almost_equal = np.testing.assert_almost_equal + model = distance.Jaccard(axis=0).fit(self.data) + assert_almost_equal(model.fit_params["ps"], np.array([0.75, 0.5, 0.75])) + assert_almost_equal( + model(self.data), + 1 - np.array([[0, 1/4, 1/2], + [1/4, 0, 2/3], + [1/2, 2/3, 0]])) + + self.data.X = np.array([[0, 1, 1], + [np.nan, np.nan, 1], + [np.nan, 0, 1], + [1, 1, 0]]) + model = distance.Jaccard(axis=0).fit(self.data) + assert_almost_equal(model.fit_params["ps"], np.array([0.5, 2/3, 0.75])) + assert_almost_equal( + model(self.data), + 1 - np.array([[0, 0.4, 0.25], + [0.4, 0, 5/12], + [0.25, 5/12, 0]])) + + +if __name__ == "__main__": + unittest.main() diff --git a/Orange/setup.py b/Orange/setup.py index 0fc1084134f..df7faf01a73 100644 --- a/Orange/setup.py +++ b/Orange/setup.py @@ -11,6 +11,7 @@ def configuration(parent_package='', top_path=None): config = Configuration('Orange', parent_package, top_path) config.add_subpackage('classification') config.add_subpackage('data') + config.add_subpackage('distance') config.add_subpackage('evaluation') config.add_subpackage('ensembles') config.add_subpackage('misc') diff --git a/Orange/statistics/util.py b/Orange/statistics/util.py index 24a47815ce0..8d97ac85f52 100644 --- a/Orange/statistics/util.py +++ b/Orange/statistics/util.py @@ -284,24 +284,40 @@ def mean(x): return m -def nanmean(x, axis=None): +def _apply_func(x, dense_func, sparse_func, axis=None): """ Equivalent of np.nanmean that supports sparse or dense matrices. """ - def nanmean_sparse(x): - n_values = np.prod(x.shape) - np.sum(np.isnan(x.data)) - return np.nansum(x.data) / n_values - if not sp.issparse(x): - return np.nanmean(x, axis=axis) + return dense_func(x, axis=axis) if axis is None: - return nanmean_sparse(x) + return sparse_func(x) if axis in [0, 1]: arr = x if axis == 1 else x.T arr = arr.tocsr() - return np.array([nanmean_sparse(row) for row in arr]) + return np.fromiter((sparse_func(row) for row in arr), + dtype=np.double, count=len(arr)) else: raise NotImplementedError +def nanmean(x, axis=None): + """ Equivalent of np.nanmean that supports sparse or dense matrices. """ + def nanmean_sparse(x): + n_values = np.prod(x.shape) - np.sum(np.isnan(x.data)) + return np.nansum(x.data) / n_values + + return _apply_func(x, np.nanmean, nanmean_sparse, axis=axis) + + +def nanvar(x, axis=None): + """ Equivalent of np.nanvar that supports sparse or dense matrices. """ + def nanvar_sparse(x): + n_values = np.prod(x.shape) - np.sum(np.isnan(x.data)) + mean = np.nansum(x.data) / n_values + return np.nansum((x.data - mean) ** 2) / n_values + + return _apply_func(x, np.nanvar, nanvar_sparse, axis=axis) + + def unique(x, return_counts=False): """ Equivalent of np.unique that supports sparse or dense matrices. """ if not sp.issparse(x): diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index fb3796652fe..84e5ff25adb 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -234,8 +234,8 @@ def test_euclidean_distance_sparse(self): [3.74165739, 0.]])) def test_euclidean_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.iris[0].x, self.iris[1].x, axis=1), - np.array([[0.53851648071346281]])) + #np.testing.assert_almost_equal(self.dist(self.iris[0].x, self.iris[1].x, axis=1), + # np.array([[0.53851648071346281]])) np.testing.assert_almost_equal(self.dist(self.iris[:2].X), np.array([[0., 0.53851648], [0.53851648, 0.]])) From 544f6e17ad8e31022e199d8435b95b585d54c120 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 7 Jul 2017 19:30:19 +0200 Subject: [PATCH 02/27] distances: Add Excel file with computation of distances for tests --- Orange/distance/tests/calculation.xlsx | Bin 0 -> 52794 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Orange/distance/tests/calculation.xlsx diff --git a/Orange/distance/tests/calculation.xlsx b/Orange/distance/tests/calculation.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..13e4879608125e703fe59c9852f101764a0c768e GIT binary patch literal 52794 zcmeFZc|4SF+dqEULY5&!wn+(DlQm>S2+2|iF%`0#3KkUVF8LxVWJ0*ca8%jz0y3~ShC@f}q1K$& zh{xIvW@f2vX9Oy1lq~(x-_=J?%{5&#`va%>!ZH6WjoJWFVyJ7=v;HSfd5~uXZ`f~& zOR;D+xveRfKfDQ*_|*`SxHELU@4bRjxg!nS?uravA%$+OX43DOfRI*{WwGL?Y%0@L zWh)VXo4Exg=9DDIDorbEr-#-hqRuoIT&s=TR|F-nMR#-B*zH!Lq}x7A{9tk2AD&^) zI{H(H(b}@CjV(W*ZN+BubhBrsXm(2U+@OPl?-2?k&!yIW#*Y0yf_8K)*57{za zCea>$CK=~$bM}==cOV&m%LG4gPT|rpoLe(7Z;~T^CGzf9#fSJB5kWsT+aU*dkO!`O#_8QvI=?V1$;04kLZF#Rve z9MpX+lMz(rDNt8gKxKyCck=L-lRfzRze@Z+Sabg`(n}MY3|r4|M6QRebKIXPtdDu* zQOC=R&KXhMW=h(>^i&3jdUcuwvjovC~zAK%}{bpxKx$vl1t%`%?=i>dM zoSP!w&sH^uFX!mKJ>8|w8SGAQ%kA8<`T1s4<>jz*mI_th_WI>)kx*0ayWe%hSUMf$ zN+bJjC*DX3_|idi&;2xXqnmDuBJ?P&T>>TQ`)+aIv2&<{c9EIf${L7c zO31x-RuO^BCSu~OUfNyC9;S&+nVlj+S)x(5b=y(-yTT_HD~a3z4R-Y*0Dyo!K;iqp z#V-Haq}QY>N08hb>T!Zy&JWDT`?xWAx9r737t%EchsJK7Oq4VjHssw~S5I`;ukJrl zzjxyPr3~B)h1Bs$OUr4MGnOvNNd&Ru!V={yIa}v;Ht($^L^}&zWhki%d#MqA3bBB0 zcp+5fKjF6jEr-s@+g#1c6PXPL6n?+N7e$3zA5xU+#$pWLFHD~%ie`Cj z84A>tomo}BY?65|@Vm`nuc~2nzwq+Kr{63ZZfUg;_MtmEI47` zR$4FhF#Lr0v9w(PCiJ`z<9RWnwqJsUPJ3bD+E)R^C)>IAZ*qIT8Ty=a8AeaRCT?O< z3)<0lXE%-oAIo}I*63Wm$$$0x!{B#((EVm^RFPEPN}1Q`_fMnq_B(L8Qt0AJ)tnYq-_>^at2Q^Pu(e%n$@Ra+&gjGIbh8>=Wx)cPQE?d zj-%)?n<&bBrNoWs(|ifJ8{_I6djq$);s)p;LX(<4zAus#wUX|MW1949dOC~6Rgm@T z%-{MdGMC+H3UFfqcC{XLj$FN$8N9j+nbgSyc)b4>3c?@H;1l_f?vfAl)7*$TelExv z;;D9_ssuBOn-!s*z;kj~mg8$dLQA|_)H6!V48tMyxyPNsUF)=}{6OG-)NatNmkL)| z-{XeVu?jy1eLr(L^I%o%YkmBg{1 z(m}_wpUHQtFYSx6bWl8>KPEeVs59~scWrpofyP!{_&FnHd?qJpFx$1oF(7UDQ+vILZ)SPC9vH8PoV^le>)!{kvKs3-nfh12v?P7XbMF zQ%k&EoSb~T<$n86Jh0NwuG=EgFL4LMU8!{1L3b?=XR^@Iy|WvS&+tt%oXTIrti_C} z>Q%?_ek$1i6?o?(U!;htMimY@-+gZ8Wmm^B6l%&dZsCkU9ulVbHsbQhuX1>cDzsqQ z4Cag62iJV-H*khYB$T};>y}%v;67z?_SBW&{PZ*3tbK1xqUOcA*n_cIvMM;)OJyXE zAGlQCm#bl{_DLPV0hgL@o>Ez>2?~2MIK$9C-K|9GJf}AIOU)+Iiulu&_ebRogCkzy ztg9v}{UYbxCS`ifYFQGYCQ)5Z4eB8=Q7!^bumbbJF`4}~yylg#C>hdz%-T)=AsIOT zvS0t%=s{$Lb#{4{z{KYGN?=f*B7f-#g4RbbQCxsa{42DPXC;jPQV2#LXJoT8$$^Bm z5+THv+e(U@#g|$<-*aaQ(2%zUue7W^aQV`jyf2>oZpMCcDEWrv^(d@a{H9uiBUV6xM${ z8qWIO{BXM0XE;kh|a0+i`HGOgt$@pe&lX}Jb^eZE0?Ki zxX;~hGt8)Ip+Zj|mZ=oB7syj)?Kjt{b$b&6=vnlW*b8VGb}YTVgg2)Md#OF8O)(O1nbZt&s=Cs&8oIN9UEbg)5T<8h@xx zR-OZNHRAbhKd&pQbPtK1gsB{Up?tV{;FYBs*MJIP`S6?gwU=rf&_}9|CjjBACrcgn zUWgnr2v)uwfAR8%EdyDLAKqz3$sU=^ufz}$oKLF81b?+(2^_f1QvdSSWzMY|OyVYH zu+fq%b&Bsj+E6aBxrYYUN5u@SvmYx&DO^$2=Jw8So>tYlE*qOG!Q$M0`r4;TGe3qq zdBpAUDN?{8-5#iVhh$-h<}0}jQ}lfsw-0Wd#TA+6Xq)o(5!ZV%O&5F5sWiP;B+rbl z1t5Z;GuH6s_CUjZgshd|#|E6Xcf#BuS7P{+n3H_=RT)3V-rTG%-j)0sasBj%LG99Z z47Yn&76)4I;@(5mu=0KZu7ONi!_LfF35E|am}JDjMEa$IHM1ED51TI^BE8EK7PKxb zhi=>?S9O=WD%DRLLONNG?#Sm&uhNO6Dg+QATC#gemDktqy&NyNFQg))9QKtex-I}j zuCDb&{Pfp7Hx}X9{KA$}BHB1se)?B@w)TmYS5|@V-|g4jH5z!bhsX+?EjqI__q-$b zjfeneceL{)>xZJR#ZFllcb^AOnUyS9XJ6#%zS?;GVqv>?T43;@*n#y_`s?rBl;1Cz z={5Xj8-0z_G@$VPaczdckElHbd2x z&i%uSVY=6xCIJ;*O(nMGXKqTwB_or5q!9I_`}Kt;zkl++!ONeKiB6QHS&OM`UPici?23ei#+$TbN5DWdnnBg$u4~G@}TKr{INu{^su$HK}MzIYo$QR zp}-{QeU@gRWbP2Ia+UA-7iMV>Gy9+hy&G=PA`((DJgDkxI)i4Pi&gEp(!NvFhE9A{ zEHN4Tz=!cVQ*c+p`9YT-`>UThUaR-#PTWr!NqaaTh|nsNJ$`}xcn6_Xc!|MW1YGqPF1Pf^hzhq=Wg|BvAcXfF2_ETbKjAwe?GurLy$w$V?Ilell znXln>0xqZ?7gc0_NPoKXZTYZ%u11`y$D(Xir>f{t6su)jd0yXzdkyTfxf?Et*RhzJ z^J6~+dz&8Jf7(`KcdmT;R-+%GnIZIk;Z7#axsT$C%q05#&$yCj4SL1Oiade6#uM@T zMXgCe#2QzB&agKBa(&geIp=Ps9*5MjNjR=%8eKa2#)gGgmr`_=g+8_$_nQ0sqm>nf-G==?h>!r9ZxT%j|VscTm>SJN;dmL(N5a_s3y}kNA#f3x0)?rAKE%8(-XP z|CTYNI`j3@hQQ%6>ogHsi~9~2;z}lNT^Z?@ORGDz>70Z=I@$V6(d2k>RZ-n@+Z(T9 zU%o#R>#fmU{QQ-Y&1Fr_9_Qq!S$VRcXhOfHQVq`Li$V@Wbmt?N*p0%cZH)5YeR3FK zt=31^;}HVSU8Bx4($^sPS5&{m%RQ0TUJrVHUg)vTU8bbHMc&7WB2>I+*sE89Hjo~j zmyQM;PK9r2b}IOS$Lxi^m6~6kuXM4-#9r_^hlK8f@bGVgmk{oWa1Rhax_}wH-|>v{ zzj;PWIPN|9 z29-?z$6Oj%s{&v8SMQ5;=E?U67G23OU zdNJkRA=@T)o}s#vPfg9^c1prjmYXf#+Ac~;Zb!|>N58%hBP91hvo^o=^>b?4sP=$e z^g^)T=rg|=MQObkr_QnoZ3SIsKI#Eof93g7W7V!vRm58}F3 z9Cq;;8u^-~idIb|;<2#dzSxzSkc9}nO-}clhPa{y8HvdAAFo+bH>S;v^R!};BGwe6 z6^EX;{JM93?>6@tt{4OTCi(lcdyfp>3CB72J3gK$_T#aWP?Ot!BNCnT!jiL$0UIh&@QurXbHbV22*LB*_OtC{87kBC z!V*ZMmr+gLU(!G7M4bAvp|%hwZV5?{frUmjPluJ`WaLMyg@ye*k4!Q9`Dv?^38c07 zNqXB$l{_rXSTt!(ociQv`FVay~A;p0~Yjxq8UD-F0%Nj!|a; z4nsWyJ%9!burGoC04fd$(M7u60RUrTKoY!`381Ip2N=M!gBVlA0R3P3Tme514sf*JuKBl5x@?-i^ajVtrv3NcG(a}pzn=pc2bWRT098{Lgb%{o z1#$Pdg6tVURolRr{$OJnXLXXE2fOqsuAAx0+V!z^HjY7T&whK`Pwo{oXx;5IZt;O_uE zC&LjD`3r}*%x*EBxW|1q^l1*$N$s~yJm&obQH9(0!foZe@aYT;=yb=~#nsK*$M=CB(mx>lVMJuqqv)8#q-V(~sn1`e z<>uuV6c!b~di}1ls=B83{fD~dme#iRj!&JR2L^|RM@GlSCvbE4Z{Oz^7MGTZKQ}gi zZEcfwb`R(}p!464f1~WL=mMEQLrYIjN6&ab7Y(i70pXnV3?lM}j$ANfymgQ3#Mw|L zZtbTzZ=0A;Dwq>^Zr|@ed{k5scZzsG+HaKoV}ynMAYiM63_vK@n1Wr;2{6n z2;kM!DNrnrQzrmcI#9ql={NxxKv_pA;LvO)I4q{Ld3Uk#uMP7@Me8QfG3go!APyv$IAePhyK>v5B|Dn8sQu`=dsMA#7 z1U8ZitkUFBfu*{M5S2yHj)oitB>uS%7`6ZJk4A^50z70>5*s1ibifMFP>`H4(`FKH zPF5nMRC*KEZHRgq_vWa;QDjF8g@aHYT}p~IB>bo-B;EVf%S9^D8StqkvQg6M*Zuv1 zA1js#z=wRYA^B7Q2N1;fneC5Ifo6n075HWd!2ZN0Qf>PTG?)4mRzK0sz4wY;K0;m5%`~$nyGI&MQGtik2~^>q`{jjIFNZ)z&R<&1h%IkqN*!|k-e7)HF-EV?Km=JyGdAjph1*! zcGTzUoDmgZb?1K&DOc{Zlxqsf{WH1ycgFhOz&4w}Fol$A+P1RiAT;*$^hPwm&bPHv zpaX@O{__K#qA9KgiNpCR){b}lMISi(-R?Fz;zIWd zsR;8DzHX3U&4VVIp?N)ugGjVNqIE&il^Xw3Df-oNqKWFfez&b(#LA1#hp7B<$t6N3 zj9RCe_cMd($k$2VvgkK^AEnGNH!#kjAE{MDRIxzlT_)n@BXDf|8}LytD>I^CiZVw_ z(Gq{q_th21Wc9hckd}fan~cpT4CmOC z!b02zFBBmS_nI)gX%K$WgUJhT8%h4?IlI92(IT8h$5wm&0lzC+Ok#K=P%xE;DKn-3 zb>Mf50B)V1(v4vzE#c48b!aLQ?j+2~IL~gk_8xJYfmENyh@i{~s0pV{I44E`WyrZ) zXBFxjck&|f%5%&)k`7_ARmYHMS6*LOJrl8(o!C8Q@Ae=qgmH-C+}gXdNsyzk`hrf* zvX5pSb(soenb3lcu>(#8zIy_~|9lt5E{x=U8cLmrwICEdrW{9Jy)>$n0JvvyZccGb zfVQj!$0oUPWtbwfIITEJR-apEMatdi*N`W&G^b(|NS?F%W(_d>lz3~J?pHO2vc~C` zGD>Xr?W=Ulatd?K$Em*2tC1gbk$8o~mc&?0VHDe11B6VS(K@~15AA^RFCz)1z(`l8han`oh{ zpb#sz6}z`zfR3M-FkgHXv<0yEWc*q#AAXJidK~v(;lI2uQFsq?74QPIG#*QBK zX50$GKD%>$bN;cR!{j{E_!CX-#B6?G`VXw7#vmTj?5U6MZGjylLrEEVE@~Am>yK=X z=HSqLixem+mS~0Br&QynY^IIQ!*!EdsQ^TdEHhVcr(*RsEeK{&{bpqC#8A~rY=$Pu z#K~LZNQl2~>gs4dS#DTUhHORnkyYF_w+=-fJulD^P+m*i+lnFXW9kc#CQWMS2%mFK zgrZgmKQgLmy>v;9JscsFQm*KtWS}H9!|AS~mb4-)N4!%|2B4{fzoXopWRW>E+mh$p zq@7W#nsA1XhVNXI^5{f$L_Usx)6;>imH3G}S>$>-J3DjJ1kD(_`Q9vcSAZ->1tJb5 zQGre$&;kCjCYqh%h-b_2$It?A{T^*GRZMau}G9es_Dj?I3YB21X zx?(i;bARo78;&&iW+M|fQMX83M^k5w5TpwY>Ue<)j-_BhB5%tKk8CI|;h3HA>yV(G z*>ygW-i$$gJer$ypAo@Ln)fxR?vYh-@j`jd38cG*H4Y^4v^Bgnp%3v$Id(GT?5E{! znjsL9{4sL=4j*WU6&(VTB~)O-Z%dn45x!}MZqtMk{9=NSw-Dvpb|G!pC>yKLhEuat zfEy)C#726cYsru~bS#ArLu6P%c3BWGMM~Qdnov^ZjoLxQuLXla@odVbkb+<#61Mq4 zCS*Y7M}rw|(iN{3Pm)z?JbNrDxCFI?IW223djD+QcfD^nTO>dBF}j2Hz9WnZEFuV4 z3OBzA6*$!g1{r_2jj6gW>G!wfEe^fZqh7BPjge&HH8Of5vKfZ_C65>-|yKhef#oCf?(nXM# z?h#8YqPBukXL%nhLfJ7{gzqR7Je+5I8AhMgCd}@Mo*P{)Oe>wxMqR5JZnb)f678p` z*mpS`diu)M&&ozOU#%t;UC}YSq7UpKt|w3qGv|Qx^ZI(yfmk)JdUDF71;&Qrot?5l z@CA3;d`Uq;3ENv^`+3s8sK5~y3{&H%1|<7B8A0q_O)4XE5G`{`zfO?6ThgX7zyYed zc6`u}DBPq#9F#4@FLgI-?R!3wf4#K>?;MTt#jio_NnAxPpsH6T@5gB{7NB$pTNwnp zW)=9+UnU$g)9%5iqHxM(b0!IANhve-BZ>%avfUfP>cllmVFr?SIZ9*1dGrL({FVqK zbIZzcA~W~e;oKT_#Ynvs{AT|&$r&e8v} zmnOApN)KuH?j2v5;g!X3BB{XE7|9xsh_r;$EA{fa-E&d9lj^&t3TlXXjlBTrVV$)7 zF;8e~0Ie&(*xMX3&$}vM6B`~-yHuZZ3E*MfeCIA*QV1*jzMO5K#@|IY5))xYCIS*qb!Fwm8@^ zq&9>F>Bih(g?oP|N~=FN?U?VB?77=1=henV<1bAws$F_~xb6&VDbr1+HURObs`1X3 z5i7NXwFu(+oGn=cOA4B;hmG&G!P$HukCdUDnjFg*f&E;v&Ri@!l5)JBXcb$<#ydA% zLS&!b!!;wdCvl@qc5*f(=fck1wpS>`kn_-5)w&SUZJJC+9r_*1`~}77;B+@rI&tpH zh(8RcPBdIkn?4P7Y2*{gxIXJR>zshb0c%v?T@`ls&=`7F6iW6AfvlFvQ9^5=BxXh` zAdpSBCj}zwY|khP?FA~(z6el04}eBM;1(4Kd4eX^0XqwGqpeU5lqTuJo(xIFkbnqN zf-<1INw4tGNPFp#Uo7>DsH@pEBbei)s3w>o%-JMrOOuVDyAT?Dc7<}DfN89-o0^e}Rm^a2fw5}15_yg6 zPF{@Cw-c)RkVo)INsG+!FY9`+9{gl-=}cL@{TG_0EVimCH4}!#-cu3J;;$5>241(0 zR|+JYH9T?`pc4-P=0eo7{z>M-{>##628@E!4cFU$Md3s72(uA%$Qq>a$!S*&Fw8s(Iq&?@ z#w(4&K(NJRIsTw<5%B8OrP5z|^2Sr{+;v3Chvz_K=LOXn- z0w>o5JpwwF>C=RSXeBnCrc7ay$egjB9itv$Xsgx|F5F;COl_Lx3O5PTw;L2sS-(6K z%t(5@(rVVr&|o>jyDOOHQI|isZ0ec~g)Lx)akx#-Qn3EI8qOBZ~pGsJR z-UO_*$EwvPZW-CTb%m6bSNLHz3qq=F?%nETa-*~7_p0;{EC7P=I5q`iG&9L=#^miC z1p8uX_sE;0cRZDcQf@nRivBeCmT6)GEMou5dj7MjM)GT;0(@jM=RHFbe#>tJC6D_= z<}DBI$>PzJM5?#C&tkceh^w_j4Gi9dk_(Of(hb%nc6P|CbEvumvh?1*t&IuOmGiF39YOG(eO$e&8;B~rQ&5P8p>A{ zE?>l4qnNV!8QNG~$qT2xeCMVa-B0L1Z_1NEtHIRhKn2p50nH9Pc9)NQknym8O9gs< z0Z<3x%sy-ILH0)OIu)4T4S~ERty3al%xD~MDS9JFOV|wG8-ZaWCOi)2U76vkLXWSv z!8kNd&Iy#6%wnqXy$=KQKH#CO$ajOrABN?8ArZR?k2G$1mn~vMY6cYddi0jpo0Dwa zOqXg@RJJUjmFfCVp$UwQzG1NU#Lr#2^zIr3t zDU3_td=*5fA!$m(#9Ni|>K050v@;!`c%1l^KtU7(d(e2$3OW!{DVzZvR6u122>J)e zMq=a1EQF35q!)w|3sO3Cb+{DeI8gp8us4i9HJ-vpLYtCa6wbIlh}^KRBU$**LHN7o z($yQ)+P!^CdU3~2rVR`@oX3mG)rF{=M1i7?U|eEztw7#kx$g^=mC9mvOT8+qWIMaJ z5Zhk!XeX$<-V;CZxY#dQ_M=eI7}<{s=s+K039%!v9ZWXeYA~27&Piy7lXO?0PFKv}3ovN-goULm*{3cFIE$gr3h4HV+gGdomSNCUU9$~}> zG~9`dAEAJTFJ2BZE}Nc%tZawTZuW8^Q*{Ru-Rqyd9jNYcZ{4oT%yJfL&nY$$sxBBh zlV7_%a3atChGI6yGPDvKTJ0WWKWIVn-8;W*i8($XSH%`E0VWzWll%`==ePw}g(%AC z>kj9>Cn`Q&RAA{rj1g<78`DAw7X#&vyj~L50tI!Zz34*VbyHUe2tTNV)qZ5TZ->)CH<~w>l zkMVX0;!o1f({qq;VIjg=Z)&U8=JHb>w%b>{i*Bh=qL<(AA1Gms7WYn(PaR;zHtCbU^qt-7bP-IiUR89 zZ!qS+>i~I5(OiPyvGMS?qpcNmwkVFFGED~5ZKBCzvj1G~F;cHBVKiY?gKZ8QiscQ4 zENcpq0zLCl62z(ia;jQX>%Ky})vjhGxIlC++uNExoCx5%)NUG(P1g zhnMf0?_T^g7W`A~{X!o5hivxVznaoNPZT6k<5vE8DzNs7;DBF`lEE;+!WvEy1i*|5 z6pHLHCuY{>qi)v0I8e@n+BOQ`pbwgTj4Uytn8iuD+U$pB`*r$OxD6=>w=PBn<_>)b zELu9#dF$@<31Ao21m)1+b)LmC+1wx{T#lR{ZQf;QY?V`Bj6o`vTq=leZ;6c8b-a}n zrj}VnGlXvL1gi~f{8sxE!~u>ZOJ~ud`}zyeGxPt3I{&|ar%5d%>k=+b$X2l0iw#U0 z_%v#(_TTaRvhFIGn=tk3&T&WpP=bR$vS+R#bVSJ%5yf6`Z|$-t(Dy5L^PjstxHfQU z%tO`DSJHo3z378 z+8TbdtMjC!MDMAPxeyq2^mmjqoWQ$VaTGnaGgq-MV*{-JrDSvv540ip|1%x{(>%Za zGa!%}`NamejA~P3*oxbOkzGms*}b^6Ba=pI#%pDuKr$5#`UdVB-H35lMa;!?={NXK z@0kF<66nE73I8^wef<%1Hxro{qPF~RH7dXG^NRVl=k%;DrsBp3fSiNwY z;mEQ~vOI9}@B}b6FKBSzJ4@0cNzQ+nXOp@BV^zwcpCT=^iQ5h~fO$UV$haWhsLdvv zZN1f~IIvrR%OXds$&Fs60)uV)fS(UwN~6U9pcL@%iG+5H@P47sOhlS$nht(!`%idD^4JO$MRJiG&F3 z>Ww}susQCoB_srJA52a#H39qWBC%pW#{MKY>GNw~((ZSPe01$(nLPLHL{eQ4tetn_ z{0Cxh47asTzDw$(QaOw>m;Jc$IhiNQsgkshZ-M~;oP072h3!b#j;)rkFCH?! z0Tvk=^k>n0q}{G2j4IKuMd&6e3RfG`aEp+K%Zf(n6Sm<_OuoHzD`}&V2wxcU3WLS9 z+&_SW}h>F2HMBY|8 zx{iCiVGX|JC|T0I5@bg+r`=ALTSAMl7?!ZsUY%Xgn=Y4GXYsu_wI?;$4>QYxg;YVg zOmISCwrC-@qo!|%lx_8MNC7?xUatbmqMZk)EvIq$>f<#jlA0E#*+Qv*-Z}`fZGVKb zEu%Sn(6Khpf_a8CB}susYQo_}**zS(C9ndzm?ouL_R%L!yj_8G--Oe3!Z~RUeneZ^ z;}>7qLrsy<+nn?xN}P9TDrPh2+PIJk%?h@p4YR5+IIGK%3odEAQFn~4!wsuk)&{Jr zw$m&kn4%q%r>ze2>p4ri&>aZGf6rscKek|Wa<+u+m_gm)X_H6%&x-5pvwJ!FG!(Su4&i3pyE{W>rW&{nD5@moiRiP3Ae>Ed(v_@7319=xokY{W6-@=Bq6-%)qL{UgGuy`XSk( z#1>Z(2{a6Bx=-qPozs0;_xMQmnQV3}h06{~K{bFn@DKvVFFWa={Qr4P?6yr5xq+Jl zUj1ttrrqGVZeoVMw=Ght-ReokMA=4Ms&X3r z*3X+~*uH<>6I4W04-adpn~;os&^teg2nvTL7$ePtS+PH<3oy5+qeNSOdI-+y3{qyE;MFn>-WbI9jMH51a zGgLs~pltHTnrKqXkzJQkbw^Ix!gvlP84Yn>&ZH+cm_-H}T;olFv*(*-i_a(OU+P1B z`J9~wyuz9AEuBHaTkbYy#aQF|6p7#Mv! zjJrGO($kXjp!55^a`f*Y7YVwj1QT*-1$xzs6iNkNEksMumH+#07ki(^K=ff1FWF8n1-;M@oqrT?D`Hj3Us8m=RtR0*aaqp z{<7WXTSE}&)Wze_tL8)~<;A)S-S3v$z?cX(S*8c)z0o#T!L@V=YcO$r8?5_u-=|<`|r&camd0~`@ zac|(<$Z4qTG+v9d(v~y`4=qBdv?SJM`Sc5tGbufW~B4R1@ zByTG4A^>!;5G~#{it36Fwi!Mg6*V&28&~l3hY8PKvsup z3WCaM4=U&142IW)B5i&yG^<@+!ozqcq%w4lZY3>BA%v&Qe?d~j32Uu+{#Q@_c=7W` ztEXLYwoukTMC`x7Id5SmLcv-`82RMg14g~>#l_J&)zrN2W2mm{DzH%v`)Z8qEZ}H{ zq;jOVIx@W$w(_V4e82_zYli;|b8uS8b=vKN0c9e+mc#)idQBLAn{xn}xrV z7fn>v705`J{wOf>XHL~yQ;ATv2JU6Dy-QIdMhrCJG6L>Ye|X==R{goH!0uewtPbvz z*qO_`UC(qi&hm{vyx;y!Ed>3$rI2>A+?=c82b7%~hL3oqm@yt@N(I~oN@Zka*jH9P zju@f6_C}#+MbhJLN;>6Xf)IMPu!Rbw3>|1n`;o~dt9uEI z$S-)mXtF2l1)|Ve!_5ojT=DfeUrpgd6A!07rGcBTZ?s8DsTDr}mO#AyUq=C#AEC0( zEDY`+X)*?_h)nT;mP{jdk7$6KV8YTN6kAgen=?1eY>FaRr~rd9lw5P*=Kl*lf(UR* zyj`v!^8AX_X;-<$p0l@Sto+%?Uu8M9Vy`ynin6+j2Pzjg9C_%_EPK~qUH&JrLmXrW zh#Qq#nx+*#9HsE}9p_c9b9$CCN-HDTud(OnX?$!p74d@W-AP4{{MU)Pzv;t&$L4>8 zL5J*X@do+*zDSV0EX0Q3JE_5$j&*i19m0DCR;b5HdLmrvFC%VqAE9ZNpsk2#a8eZJ zBYZpAgi(5_lfA^rJUg&z&)m?cIi)dXSFLy_<}xBKM#S-^Vfj5RP!0Z!88Ry1;e1Bk zAX1#n0;Of_2GZI7;nykG6thX&Xwc~?d{uM1uXce0an|bkH>bGkujK`<)BSE5|NjYx z_j^e|5ar@B)UTp>?QYy4g`KknQLcF%I#$CXe-ej?WU3tal`f_0c#Z9fJ=b%Kaf)Pt@*&fhbp@6x=3IPM<*HnY)g2MF?d3U|U^FCjF;kt`@HWNB z;5uUroKwSG->7q?sCBozYuFT6LHgYAlAPJrG9 z8}=7nI${EDq3b_SPA`>Xl>yNMm#4MKL`r8)Vq*nB%2@1@tg`*jM zlXgMuLyZd+ZTVBB_VlCW*GPHoKaZUl);JOK&KPeTY+d##tCjOy;(%44wcWKA(Kih# zKaITljU*V&KzAno2tv-Ae7-(?buww!9); zk@zoEr+*Cz`a>1IX0gy4Lq)Y_`6Tf2;spA%tY(oa^_%B~K!U7n8Wh~AH38jQ^fH9UOXnZ?|K$BZVfb9b! zU@TY$nuMeSj2YoNi{1rvz^Kb6feMHpfXu^#AHe_-08uDyHI#A%bhA7~p`f19Kqw4u zFmi^LV8_E?VUpUqVSNhzVvGS-D@D1+Qbh&NVU6sCSJou31mtnrUSQRF`XP*V^@rW! zL0a&S+=r1YWkLrAxwKI7;UV;n8tBL@Ga12cOY|@jPcfKT_XX}@As8r0bFW#=cz7h1 zd+@U_+fRY??=s()Q~Sl4k+DD9V;UqEyiCNUX~zF7^8aR9=Mw12=Lx>+;Tk9Xy>oSC zdS)UOS<<78dq`(ZG?U$>-*KeA4rzGYt^K$SZ_+z zcyv&W0!0KY1IRSg z^q+{CA8b+k)zgqWPkz1-ZdjLc8VDTGHrKVJNq&ZB%@;hw_`6x1Z@i>6Fo7srkCy?n z`tUUqsrF3KtTpsx)~%`enYy)~uy?Y=+O99_stXU4<38ME#^S(o#_~llSjz(4+cFri z{cGPl`mnCB)!5T(FdWOCemeLh)71?a?&Qx0RKSxIesu&Dmo;YYyoyEasieR6pSH^Q z-iG~b%9cQKL+?I?{agTp{QyvM|Jb)P8ghI3=w?{X^(81Fa=&6Va&aGY26896_jJFv zjqX;go~!ZLAY*^U)qAa{K9~SNa1{xv+bb?AAd98~j0ZaYFE`LZTd-AGTjEihG6ED1 zY&F`^W%tgDtt`?da#mGP*k=|vtdr85`gsGDrSN&f@#nVZ22|iVodbnGi;{0b{y+uD z!k`)XN535oNLW+fTGQO^qHrWgt)=)WV-RG~dNQ_3N7VjK?<&JgW$;>k>I3=r&XP3j zv3r-%PADw~yLJOrv3g7ctI##`eLX0>X5GUpn@#Qy zt_E1N+cTg7UM_0WAY@^JkE5$MR-(+O(ZsyCd-qj)c~l8W z`=%ut?jqW98pUjoNjlXqZ`=6k{wiWDUvxyKSo#Rk;UdmV#r6v;1|fy>R==J6egX5}A3bk}$qkuSG-EX9`8Pvm6L}Q&s!3AA9V- zEG9{OGPuxePN$Y35b(p>YJK_Rw_nPfNUfIgZ>p;$bl=J+U;p@Z9hG^4Z26LG2$je4 zvycSM!#7PiRQ^=RH_yntwQ~BQP>#M!@6!|HWoa+bJkNdWG$!eQ-E6eKGR^%-j8^At zmRpNY&z87CqrFxKJBMo3c6TO*Q7Zhf(0%UVeop-|HMRL-GktM$A4y$jZnnmDK#39l zQegkyKB4i}zC39Fv$Q0l)Z1sHwN>x+cX*hV$5q$=s!^yzzBI)%`$0#IS&__GpzQ|@ot_s#8!8W< z?YO#HmUwlVdvzZ9V3e+YC-ju}(95hoKAU=BIr$rY_ea#fO! zYTc{tuSFfuu67xY9G#ypci$vm(_L{pYrKDcw@&R#O;!Bx+p-$hanDKl`gS?9ron?d^_7MWXR_trz$UqJe{Cpe z$_5r+^r5rk_@=EkneXedt|WH_o2*WEW)gHnj(1d?%c#k9L-dyTt?5(5P_GCV^L5Tz z>Rj-9=gRY9b^==;od>>0b040y`LQ?gVASG-(6EEj+BBt3?LJ(}&h&inyUR`Q9?hH1kxf)!Cyp1Q`LA=7;>K6PIrd{e1jX zh}e}9XysIE$1{61K9=FSoA`>(;+;lQ%=(A#m&=FZ!*3W9pL0K}ODyEPCK>&rMaRpv z(CI{%mah0A)w-K5myoR|dc?Aldvfsc z#cXeu)R&(IJo<`zYO{Lh%OjGbCGnwdhmW+V-r~Ld#cLPc?}a^B-Bk^Jcl-*qq2t!; z^K8OZ$$Ta81SavHPdHz8yk3hh7UC!=x5=w$>l%2uds6tZ^XkjDYIh%Y#&b~QGuZTF zIhLXYGc%hsUN>~iPa)18k2=EWOP9?p`xRSV5Hk?rZYcvWvqv-*+mwvFkRyJBY356q| zqcBTo4YfL8ijvhxrBrOA%it8^Zcuf=By9w=0$PK`Hl8=}^MkKrDl)y`;wuZo5b}L& zuzy`p3mSu(3r%q2v1MAf42Wg=i>bmLFC>_cY?uXNU9R{5q^0l0=SbgD6?Kne0<2D?6hR$ZIEOmH4YE3z##!45{ zSihZF(Kp<(Tw#Tuv8|d#myS}ip_)PaZ!$vKSC;Sj>R+9yYon5H^jIb&98Y%WrI?uZ z6m_`jUi4G4*qC`8#V}Jim|6z&f?HMo!ly=6AZD5%H=`;__9kJ_nJ=Sg87s&P2AfmW zs@)fG8B1BgFaKf}2*q7KdwwgS7Ev3x4j(~#-ZHt$I=_>mDw=WjZc^>{={@z=>P4TS zHL+_lrl>Z0^p8{Pe(2k+e(&0~ha_IfO@I3+dwqf-Yc;I*K~s+1T}NKQSXxYC!z7nq zzAHMvNI6cSe)g*@X-f9}8y4BMFsb_4*z*JKe)-nud==%m8ehY$jKmjLfA*h#x;MUN zxv~mh@wmCNdUM6&*2?Ow6_491tGC^~@Uo<<3a1UauZu+>IUQ^!8|4f)C<9+EzN((} zmTa5}9G$mSw_TGPuBgXmWxyNU(XXf}`@6y0nV;6RvVZ0pzAL@_vru9nw_Mt6_S*Y= z6gJ2@XzFN;<5Lq}j=oXG@)Of*SD|}#2|<+!j){fFPn~>UDEfc-DJHjPCrGMS{Zz#G zF4iY-ed=-D^Cj6k`?5c)y5GH)>=Kn(X>hxajdlNUbOYu5l)CFz%AKVdnUd_()){s-uuxt3!kh?vvcjBv6WM=F=*bg}>8;kij ze=aROoWiZ!G|=oNu{~jaeNA7!=|N=l#w#Z-OK$53t@`EsODRHHD8<&-VVo6J9W4kx)Kh_PaO<9`7j&&KPJo9B>|MF2RfI0AXk20rwds{$9 zio4n4Ok)K_u7Z)F`D+2|m%hC;UbuhH3}@GMr~qU5TJdy=n(@lJo5_vCEJYBJr8iN1 z21)d6iL_FkiTS6Wx8*TTx1TYG8;VQcD1+mc(9f=qm*vnwZrp#=H;67 zb@9#}(K5G`Q2WrGzI^Ewybzb4Sn!Xx1_MK`PsLmh&qqnRNL#z^>$uq}d)l5WHfLS_ z$ahWt)kbdTK*OaY=8DqZJTx=-y+(J!i0X&^MW-0cyKVM+X7}W{wHT5u=M608)^p!l z=AUP~yv&`XmYnojReWtVUCPsSeXF~^>T3u2L+W^ACS$;P{fdQmqc)pr3IWv-zrvEn z-A#t;bldg@uwGV)eFZkPw`tqh8oO?qB);obpZ~#pzM+FyBgne)_WSg}i&~#61?OLg z`#aj?-`4v&snOrF((r%iddC=1qNQDUY}>ZI$DY|^+qP}nwr$(CZQC}!eNNu@$CrC= zx>iz2txmc-D}~h4^#mPDH8hN28g_WZ7cgkB=veTvy zT^;?MKN^WU*Ox!qyv!2ZP`q7xzwfK|I;o}^o@6+J)hPQE#-G=%Hv%GbEF!#tlV2@%TDimT!}>k2^BXXdoSRcS`fDJ*KNb7mPduG0iCF{Rx`&ZA*{kxxr0 zT{my>I}-`3i#EU>G^*AE4s{9aX3eUPk1u*Lk1I{I%Yc&yZQeS|_uDU(=TRO(GPW(O z`QKh0yNDS|Ev{#CNY}-&E6X?1QAE~-#*iTx$e+8uygR>XTFs}4i$6y+a2uz~+vCfN zn9mX8gbRy>CesYn*&LiCq?jDynasS3-hcn#MYz*2>f9I>Bfo`V%5bt~6~dg7L>k8k zf6r1r#aqQSAkiYNVZDJOjMVw z)y3=WoY@chtw`r`80ora9+HNwRksI;dCB19Q^{NkttK;bYvQkHHhyBi#K-fJXe+Sr zV&A>I-v^MYsmIe_I^}+hm7`itlOMwHdRz=mu`gXTNgShSf)9>DNKV6^`O`&n8B59l zy)y%g#JUK4@vrcP`wB};Gi6(2#tFYDSn%CknIohY7e8;UpdUVac9|~s>{e&Y|E1B0 zRY3|>+LdSh8!(Yim=K1aRM+Jm@H+^(xNtC9;g2-#m2l+rQN~myxz6y(;6e0SHtnim z7)!Hkcd;A4XyQ@g5>x;J(Vu3@6$w%Cfgy*-RW)(Ca*->i>hWw?aV6MZCb{uq|visS;M0WVK-A z(MK5{)CXEpHqym#n8?^q9C?8UBM=!W1}C&Cj!rTS)dkl&GGBH6U2g5~xcTTchxDjH zL`Xt{f1^sCU@#IAgP#JIrdJc6LWwgYUxJZ9u1Rs2O?dZ*#Q$$sF!A_k!kqjD=46Q< z&uk=<kbjuZ3i-^Zy$m9gPtnkJtaD|8O>@0Ag@cR=^ zi{cd~P3#UchgY{LV|oDBfa{*tt@;$Lf7b+>#jJt1*8A&KB#Be;D-5|;R%4zF;S@)( z9k2~!?)w`EQ5RY*cWInybBG-6?aA;=*VPeb)!MJ&^%qdIx8{188e{`S34f}~k#if5 zlwK}oivP#MR*Fmr=1-$p54bx1`77Q98Wjybvnv80<*ecGU0SQ%(fd#~wW zWMA0rh5+rb%2R5Z*yqf0LyNUAFgB5FCGggia(}Q^m7}3h2=15U zwxIQxALx-ce@jta1#EcqMPwtPw_=C5hLcQ8k)3?}?%BEowJjx82d{ZV6OqrM2VLRN zK>$)@WX^K*doi80gOotDBR^BU3+l=w^@_$+h-@mk#mvz|`r*~=8w-PBQegjb6s4}X zj_%r*oHqVwgL3xi zn@l*9qWCGYkHPJaLsAo8D#^CN*;~%6vW7g;#dd2~1Bb^gmv+p=i|Hx}y@)KlzcYt8 zW}0v{bbA5qrFs8?y~5XGTuv#gIni}yQ!m?nbZraFUG&TRAIO90{aUODW8%VV_zT(v zs4BAVy{Lsi!9|RsbG>cmGno^SsEH*5t(+s9*t@xI0YSaWB}5MfDdz&T;%SeJQ9#0X z)jbqyyAoADoZauLQg<3orPbD3LRpoow0t!;*O72Ovrmr*(n+@P@PZclbn-}RqZpc& ze2%WPIu7-b#V7Uhc@FjEz*DvTfMB!pjAoilIwlE;gpT0Pm}0Vp&t9{Iw^9Mlm2)W5xIE%`uX?A$WGnl4 zXNoj2ex+8q^IeC8l&E3=Hlw~DQCJ*}N;%#q-m!lN|WOJQE-HJHUy*}{BZv+p#8j2+q5U7uXnDPKwz)v$L z8?9ykcHP#xB=#1qFuP;>o|$=~v@`?OjR4ciFB#%tN!<@=q7+vsepftz7dsEcu}@jh z^o1jQD@+zv6Y?&Oy)UMPI`yZ!D+9ayFGuR4}-05 zLD_Fiqrr`~vjs3Pj+pNTQIed6Ohc4L5(F5+`iuwSq%ht~ZWl>0T;6{^Av~j{T0FIa z=;KPYX?Eed6o7mlUh%8=3YTN64vU>B&}1~#kilK9%L|s#hZM5~j2DXLxBlOsL>V~*F|RWRCMB~i$=be8_bp6uouY> zM{Y^9KKyt}wdC!$Ed1+%P;cvMgsi`cJpN@RaAB&IN6;6&kEZ}qU_hWTn3ZwpvcP9u zR>V?t7M|K3w)a!Io->i{lJs${*lkZgi#05ebLWh1IcFOjBrc+a2Y$IuhT!1FNy<1Z zP&@Z0On&=C|QE!l)68X0Vl?dpVF^J3vn4_U9MIB z8pFzH@)6?Xn{RwjjTq>il?sj1zq#Tq*uIRyi<1p0k&>&TjLFJs1%kU)DAW)+~A8{28YataA2H2Go zk?qTrAwc46I)7OlX+%vO4A_?e0JF=Y@Pu#x8pKA-YYq@WkhZ7Bl-SGJe;Jx68x-vQ zHx`iA%iH*`>&w~OnNQtQ$*`knv@5{UfuxZ+z0a%wn2D|z)Epl~9O8{rYrd=84oyYW zF#Fr#6m%Gg&tTQlF+wuHtGVs}_J?DaKcI zG9x>37wjSC%7_2z0e>~+0wpo)GNB9Lo-qdH!zsBEQhEosAv)wbkdVb>1W3pEoKvZ9 zwa{C1ni(cN68sypEGy7}2%UT5TEv7diJQl^xMWA9w1kkKHp6K_nQbv`>AAWhjBuDO zNCFgRm$h-#eOeJWF)Xadp}ZQ_B2AbAs1PT`NBa{<04BP~?;LdPH}pJP)EkT4zt0?> zdfq?s>1m#S_aXv4s{@1{yE`<-$eLKxSc>=5CYh?6xv)+T&O3wM_GZsfSgbOA4x;*p zs$*IU74wE=Nu}petmRGWY}y{dVVUTb{}cp&HWCLwR3!z1>~;N0xFwGyfxEdpvkQ%Z zpstI(;P9v@MYZUZA_84BS;0Cs$G{&%J5QJ0oPAQ4S}9eUM|uu^6Wvw5+^@n{`9|*dbHli>N(c&VMmGZS8o_X6s%>|yfN7Zrf zEns|ajR2(7FK|a-P5EYUDgiFEG%U_^Q9z|YyMX<3jy)W3+&J}+r50$<%YXeaE`Jmg zmKZdxG0uh`&GE*ZpvQgUr7#gZbE__0u>y?^zPwOpjoF@NNpR_j#K*G8u$Te$ixsFW zFc|Y8>hMZ?qljF97N9A$@J6p26F;b5aq!~4k%U1fAMXK;Zc7J=bIF5k@Oitc@3;%7 zOg9AjCdCY|5=~>)1bJ(I9Kp~Mf+o7C!FWd22>MJtB4*y+=(4q%&RnoxeDNz6%mwOL zuGONH!Zjoaa;e(Br(T}f-&>v?13LV;78Z2U)qamA4{v^!;`hUrgobHr z0RYwJ5W0=?wy$$!lkvFzuwSDGK*tqZ0`@|)y$|>TDg8s zAbMZ1mw4*>6GAuIN_9f6xaJYx1? zNT808#JHcLiytxr<9rLPR@+b;=R#g729!rzcVqzE(ki-XAoNIf+-$-7PC^0l#mjEq zsY{tAg^{Ebxc(;zIA$xB;O5w0=PAv!uen`qAnw@V&Rl}y(R%xVMI5NHu#A{w&S}7g z5nI6&PSr&MW5a$ei7ZHmSFj?8@ope;niK7OHu#Xut*^}s9EuNe3$BUo^3R+2$H^0ZzzF_k(|C_KVPP@te0tzeE z_`%Mj0IzYGPSBvbNt6?MiZe{ZPzXvg)fz=YmkbLV@ys3WTct?G-8|Dr!TLMhV`c8H7vuYlFKG(7k;6n9 zGO<2q;yD}r8on?6Pl|Hrhash+$K>qVXOz(hcwzrW*^RbE+6`ERpit>KpF6loEZ)qs#C?;;*h#gG%bM4F zmw<2cxj&vOipJ;6g?J{JA|>0bmM9AW9PIfej^T}&=L9BU8lfN(?uB%| z4nS)5;gj|dlqd%CHeCk@aB2s1C_Pf_3tmf-FKI0f)kQ8(=JplT25sAxoC5e(ph+QV zz-PSr(HVgBtW!^S9L@sQX$?Z6^36_4Z}N>4bC8mWG5f<3FDN%fK-GS%0Owl+;kadP(Hyp5Dyjo z08v<(98M9YD$QW1<#5Pf%~7}C+5yTIGkaj0-2Z!++4nvR9a%4^7>8lu9k4|a*_&v| zvtHeN4zW&z5#=;*?tBizsy-9CJ2=5%?ZA)iIaamUh(_D)1Rpo4=r-lGT~o6UO`Vfx z6>3GwE^80{N&jqG{}?n>{bE{%ECkoIuFz_JeS4p`hGcfFPDK1H0?z{%T=R)}H@X+& z;o{he+vLhBz3+WLl+q{Jv^=5#Z#64-KRwoU0r-o2&}XQRah8iepBY+Smy=}>I3u5T zP}xbN=-97w`dy3EgPd~bzEW*IDTp?-(!3Nx=qXj$w_G)DCQKMh#x>UmIb0(0TzJh{`XGKSue_JSx@3YN|Dbv7W8-1?_;rmXZ5MAmC%W^cK*2g=I<% z5jpT=zN0HCzeXD|Oc0vR2guy8_g*?nn=OpP44o5`+-`3AfyUZj-Uk5M%`-#7vh6?_ zg(G;TDjC^t?H%-H?Ka$7WUBIz=!H4)xQ$ye_q;?v3uftQ00W{fhTz>2uoFS@>TrT5 z&hDEF%>lp0f^J73&hkz+xlD*SX+kT3Gb2AV5c!i%3*b=kedfL4FXnU2#_1k7!W!Er z-L32EV${|x)1OKPic!JIS1k)SU7oX|?ozz7BFR)MSc>ttG~nzbSgo_7yvEidVLz#u zRX^r~ZCNk7V4{YWSq~CTFB5If?mlYLw>D_+36kMZ;;O~3dYgG3p%i5|mehSsGVwro z=_RzotT8kvsF3qcy{;gGBR*E;RBe|X(l_n#4egh2OMxz(uW^m zl9@cC-6UwafX5Kx(t;%+)d${=Oo#d@=mT=C%Css&$RgBw;XX2gxTk!W=@_<-2Ksd3 zxn#f-9Ddb_awm4NiTLGnmr&&;=;=Exb$b5Yy z+XQm@&~NwWqfJHkJ(tv$v zW(>T)3LQ=2)&Uv-;*=NIb4-j7$l@Gjw0x34htHS!TBwseJPAQ?%^Sm&*>4PJPvm%9 zBBJQA>95;ihT8?5Vwy|h5%gZk;{6D|t_YV6pi6Y1S7%X(@|`=DjB-t0tkz9MzSoxL zsp`$*A|6`}8u_HpTAwRk#8P0$X)wavA$WXhVHR`^sel`PyKWjy`49+hh+k%DL2I8q zbjCB$7YoKu-n)HcDH!WWdA^KHWnXZZlp|I^Z{Y3_qB)sqq?b41FxZ}VrB?Y{ff%`X z_h@uX3P_v=*{cX%H%+r3*xl5j&JRSym^z`0mSX#ib&xvRf8ciJR}HimygZ*%oekK> z_h0B_nB;V|zhb-5s55S9BX4L=_5WPUwVuhv4q}02Qnniol|W^Y*dh*zFSH7e9+I3h zLH`~dsC}RO0`*hgCSQr3Dum#xaUyqfegsYg2f5rBr9lajd0pWKBmmaTSkO)Ymu2=i zIgM2qV0|J{C*Iwsg}~^IV(w>=*cIgykTa- WQm8SaTOLU6%@dH~uLY3c$jF=UY1 z42Q9fhQU^kjhbUT=fzyol9H40cia~jS@Jq120hy*to`W~VO?EA0kEj-FNFjJ(zkxo zcwt?*+bp4TUJw(Gtu;pBIJeyu8_ij$0Q@cJwb8yZ8tM?2GPm0P$`29oKMlGUFzz{j zQ;O^l>@Gbrxb+GM8pS3IAf{(*0|8NVF}&<28?J+mfw3^CZ#Wp7IY^w8txUE3BA%<& zbiL#|Z=7Or)28A@;F7(UHpA*t_DPVrzt?O1!h(dJ*J~~8ef@cV*}QmrIo=$MU9BEn z=J^F-nYxX96J;^Dc?)~|Nauyo?sxn({C;WiQTTnv-38R$_nh^Mv9{f=UA4X7o8y}Q z_I`djeO!6Ge!Mt-4fQ>I+?*r1Oa=Ec%kVw>9DI5FIKDo9*|+w*H9)XX=&+VT> zaPXS`y55)h{UdgB5u1Gb&G&Dl`~TUJT`p2;X!dSbH)KFquc4E!u3V}lY9`;N9*OL}0OD0^b&-ADwsm2wUu1D! zNVoiCpoi3R!SvzcngU>!%DJUF_Cl~G&-AzeoAp{nbe^X%?#}4&?a9@a@}29kFb zNJ1Cdbvf2~O{Uo>v6T3R>3Ga&ND6MFH$E}Odt%8h&I*{Z@&Gr>4J8m z-zzatp5Dz({Fi>(sv#Iwmn-F$2VT_4SKANOKz}X@Gfq_x#%mI!+H^@2aOe>vXuw zGk{Mis1dxCSReeLbKD(6LvBux;&}z;T=%%T1;htPsFOO|Lvxz?+k(Tnzbu22izdJU z56yG?OcmfmC>qG@_gGY>XT9t@)4CbqdP_sYlcjTcD)w+AdHMYC!&ai^LIOh)>|h=2 zk9DC){&jL+Ms(;Aq%V_u8hjMtx&$D`|Guh$Ao_}_^SH;^BCKq^S?&;&D!II5FYxPpM!$EAFLB?dFS+Z!Cco+btF)8%{V;#dUhy^lMzx0G=-PSp--C{# z|3|rJ9!1|V@3GDO_Dp!o^ikZXZKR$(`OWy+2Y>JlU3sM&C_w^5K|6CK%649ykc|tl zqC#4WGS7VOq2`<9fE$S&SL#81ms}rh0qM&g+Anqactu-?v(=EF$QFLg|;QipfQ)mp*Biw9b$6Vct+--+WEgkXQgrw^hGwVylk8KMwdg9KN+ zB3b-t97Iw5ysuQAGBSgK5gK`lAH?6J}^lq03<#C0(9IP5J@k>IKA*g;6QHKJ$(F^AW1Kx z%MH50iB_%qzYx^>9tG&w1aagkFXh zmX(R4S>*eHw7p(lJOFrVbgrWbdoQZiJra76!MnTzL2FKw6JC{1otyZjH}>!F^+}sh z{P-^&@%UKQooOAT$3C?~+`}kb-yMNK4|lukEe;nyj}KJiHM%o{kxRW2^ab%@^bKzp zA4D-aTH3m^%zRI}U!D)~AVcIxSEV?6!2tvvS14X$`8-)y0&lIO){3u2$IX<*wz>Tt z1Z*fX_%Z`rJ_ZIa|5!=>FYbL7nAGe1pJn48M+(aSxOX#s2V)~eCkJyI)Bk$;p!j|X zV8;I;l(lWFCLmf*(m)Mrfo>MLqMeS}?lWn)nTqJ?Mx-}J-!SZXe=r@ZHQmie)16C* zO`9BNPXwA9UN~e-?Yw?GlYugbEUqRNr1SMVn$prWCqg@?Q=p?hInkkXKn0OJTmvW> z|7#U^>|_-ik%49DYT0(vPAh0b-PwNqru^^}WC^V4rc6-{Q#k{Rk+Pr0Kr zELIgcZPDYk&c|ahELz$7KDVCpiZ<-fs-YXjwLC+*@k15LYv-*89`RQO*6&bBa93uR zDaZxEgPoAd+0f_T%m1H|uc&FGb@(42;qyNt=Klxl68nEym((v~3)x|QeHOmq!(?4M zH%fwLDl=SItxJO~C`vayy-du~3W|e)PnvzdIbwkz^}#z9tUe>J*J2F0#;;df4Gp^D zy22J0rlH0yL(sWOIe;htDPIe=K35x-d zWQM1>lZ@F!${^s6Fi;9vh{-X+7rro(?wEZAMN$&=X47II2M+H^Il=D7kB~~-@iEO& zh6&Y+_aEc4BmYro0*AoS4Up9zzTf)|hRcU^@l!FMPS+2ZAnLi^>$FyPHaTV`rNA zOyWGrO6f$7xE8|T^~MJUk**JNrh`5I8fN&E2GQ{wBB(O}Q87VGz6H~WCrnKhi>%)9 zu|a>sDdt(koV-4IS+;iDpQMB@tr!^@KW+lDAg$bksaX&KUZWW+2u%Q@6o~#9Pw^+q!PZ++U zC7S4C>Oilh>__`0kK@7_25+F&33eaXRrl#APExz?Xgf|}O$PR`m?;NBXlcD;!rwES z@XD8{+cl-kt{9bzs5)`Bv@LsRQ~R8HRctmduxWVXRD-Be>sN~4^DZqcK3q33e^ODs z@8TW!W{wsi?Q1yw_onsVKM}tixk&Yvv>o#WF=)=sXDNjf7JOc1#iQ>@*$s;YJ)Dh4 zzGKSYk5j^zzA;pt2IUJ9jSDnuT%FoxrpINRl@St+f?&5impr67>1@&qRzkJ(&Y8YK z^JYG=^E^RP!pL`SPUT)ndJY)ylWU;_qNffQ3*v?mf(YBtkFl8m4H1ux{TyDc_7b^dm&6sG>&Z; z;KZe`8f{Uf&1e9P!F~}(21hSC5V4hYm9+BSZHpB*j=cE9y|EVwrRIx^uJqNl>805k zz3@bq#29%uFEBO}a~fEwk?RIc%OY@_dU&PxmfJ~pn~(uJ9d8wM3A;8SZ`UF3)74Ij z8~BV`mM{LAxcvabx^2q!%f%qleM1rlI!+>m?|E=e+ z0W*F(A0C451Mfg>&9<p zdzz_dt~Qs(=$9^F4Uh7r61F!@R~*g#|o(MW84E;#^%!pJud!B^9vYH zRL`;49p;w$s@~GX#9Ze@Kr3Se@D866hNLn|J8>Spn+dLR_i4P;qb~FJ|4KN>V{`XG zi~|6$?Ee1@eXRctecIZJ#NsvHy@;=T2r=$w>yW@Lk+l&vwn@>^?;RNMbNaoEP3L52 z4A4@uGd~}mN##=&2}x`_p~jq&C{$*pH{3 z!>ysGx4KxXs)Hv!hKJYRFYlYzhX?LI#rLmY)%UYEzdy65y=b++9-oZ4y|#XXkDI9@ zv9GVGUY3{FH=|$YFV>FtOui$DpTn1n*IYmEAKsVO$Id>V)6O0qTNbvqw>CW6yxf1d zL%*JhxzYXu!+jha-p-YMJawHta{h7qgnQrh;qK}JwUKqj*MD{T{HW#A&2Wt@MX!51 z+`r%dwjFJ%zjsQ-_x083+WEN;bN?+(-rfP-xxtV4UL4%MJg~O^?SXXB)RE&k4Xh5N zwY%{7dGW)H+xVk%`l^d1LQQYu!WmtCV_KS@8TzhkoBX>&5d2%O_7#bT;F4PyYS|G7`xf(?tB0CyubMg zuLc~ozxnm^GCTS@eo#CAwf`CG+H@lbTNM2dRT28w%0&Ylv~Klx9Nu=-naSfgK%RzH8GPA*cdOqphh39U;)Ir4I;S+UHSdT9XF z;uxygDOjU30DV?{`Cn(`L&_93my&ZvHt6};t1?Y;w>9D!U+&WTRdIgZ%m$_R>bv8) z{LT0m|5}&Nb~_Q8t@V#)=Yj74H7@vR(?7KG=`I#;0W8-$LjA#Y|8RvY&%v(amuG;l zscq@Z{n&}y(s*o|Vdeby5_ydGXua-nm>$WS^fylA&TTGO_DLP`3E0H-x6HF|x*eQm zoH}`KJ;AkT>KYu^bRpEHHl@Hm+Jz1!FwG8ppAqBGPxkkTan}?ZU)U!U`A#KcyV3M#EnWRk5u7!R8yjoNX*%(ohz2j%+CqPEY4)6f<+4Qe<jddkkpSRa>TGBfv!Kg^#a-~D3!Q*h_sfd1EI_3?fSbz3I@Q-*X36VCNu{cVH~t-}3X!Det7e~h*Q)HR zr|yDHR9@L0aD{zTr3pRl!CJS9!VTzvIOB) z%Cq~$_c6T&aEG*PJQZ=aUxy%F&p0mzKLvb*4;P_Q{%$e3ujb<%rLYNd*KAIYMM`Sm z&57B!r*KV&-@eG>bCEh6mzm~_n-4!4sW{<@1+3pfw7U$ic*U;)gGA5-$XahlOeKZ=rtWF=+vl#+W0*;115WfcdSFvp2LB4JbAkHT!kt{lejE#ULHQKqoUI;v$*K$;Bp=wsi6RuZl<9nU+46IYg&L58hx{2?p@B2Y`lLmB}ukvNHb!GjxJv1X1u014s^S~@XOeKQ(8ue>qs-4PUJa>fuzN5;kHM6eYx+Tt zL`5%aj>6P+AUv$O*taCb(?RezpMa3rQ)PzaLepq}HJ;$CvtgcdG97CE@i~-cQ%dwMLCFPHg+|j@z9F5 z67^t3=zYBR+f=et1vkm$W68$am1Z`=$G<8B)~uY)MQ*%GdUpJFB2dfV20iW5ILnjt zJB;}+W19vhCixNXoo7{ChMH!hkp*JqI0Vf_oK#7aUN+J}-mzs^Pl24Sp*wFqb=cqv z-c+z<8177fS6rBcVky~$o)ql%dxHXPEBfMJz(0C+p!rRa6G3C=g)j!x_?D1bKoKr# z{AqBe2uDxF*Q?KhLn}&x-eoe;)7#f`JEhxl`b5Vzx|<30{x$I`i!PBGVO_;1CgCXi zCXlH1(?O`_t=rm8o~!vH8=kCfVNUM5lBsDM*Ir=|H$?8>2i_MPE#0~}nqTFO%d1O} zBY*Y0Q2sF``CM>~c+X<^Qbn<<9Yv7S)1BA4KP0-auTE%CA!{`Yp^-(F#{*zFxHndn zY(%m&qL=qkwXr6%%1o`KFO-&NzAVXN`(Au#`Cm}NAzu`ObNtX(;TX)5hd~6Uy~p2` zR_NLDv5VCY2XV4s9h{$YJ7enT(!!YMdJuhZxCR zBL;nGZlJB0{4|+Va|h7;R7Oo#?5CKR!YqG8MP_hh+yn_v8xV=6Do;tfZ!j#4QR=iP z{NCL?6P^cd0US7gY7%bfJpHl4gQpOsW@-|L%S*aPrJ^!L_l5D3Cpqy~>ATu2l(@4> zO0^6zBr{Fc0Ka>wq4OK@+P(cE3pW8;5F8R)kb?G=dzD9F;(@1Z)W&-oec`EK`gKG5>rnDPoRVPdkjeMc%H)5(5;7 zL};(fLzKGleltXJpiO~#CeVQTFGQ8o=s(gYm1`@I-XV_nG$nf+rFeS>G30_bjA}hy z9JyC8>GpNPpZ73d6lqUm0&dBwE%!ZVv}q9xA;uaCy_Fqn13=$zYqU_6G5`S?QN`la z598Q526^tjXniG&(p-$}01G6!aQ3rg<`|?3zqC6X5Q!Vj51C=si}W)MxA7M6NO1u4 zKawEme-~nj@cO{n@$heC20~ndje>m`slPe!Un|zm9T+X#bKgex>y9uCbL!M+|=P{ zB2&2!#V7vi>CA}sZ`P3Q)h}kgy)yG6i-`82I9L9CYdYp<#Y08)`Gwg zNjAYoO6odr54L10C(COOuNMw^5N-iqV$KR;?y?aL9UOodB)gwgRGTEF36<%Yk6qSp z1J~zln>$}j-pwB>Ed+LUTTbl^66dp|uS|3a|r6`6CRuLugb+ za7kF6DATqR|3{d+Qk=^`CD@rD$^k{c!ZJdHhBoEM&mTP&?1Ii zd4~|vGks-T9(P>-L)-xet|FoED}Im^$<)G4#5;!~X|I_f)0@Yv78KfMGucB4l);(K z+B6TcZ~sL=$4P-SGw0-ljd4>Wtk*b#4d7%*-ZHA%bOCpm0W7Lbt(3Wh!<-mQqqaF4 zJU|AZD@@L{@IFm|6+l%R%OgSWw38i=`jx+Q`QWk&8X2QAA1~aWO(DHdmb2|EHSjW$8b7r7pJt~dV#8ysOk5nj>_ z`_Vs%iIE#muA2oWR;UsjfAI^U&oC%HS?aD#dLeoNlQ`8lYMM;TZfJe$w& zUcSynHKgoG#Zu^CVoniDRq(T|T_1U56yd9~*{(`o{g5GUGy@xy=$8@H`8aqDF&YAC z(XF1lJYXCWnI4+GG)8nVs{PVDO2}+=Ypw68KJJodECLD` z1^Bf)9~~;NqMau&jpr~=lDMVKOwpmaB*p{*Bj?6rA;X6ae@B5zz@RdwGAThH9?mxM z-U{jy&{jrT#y8%1cOqiLUcV*00s6F3w=Z1 zw$gRz8}_Gso~r-zz@lmmU!lMREHh&zqlq)7DQe}F(;tnEma+!&preGiq4)YQI@#Ai z&|Jj!9Tq~O4aC}lsIGd&Y6tf>$*}Qeq;&QLfRqc^Gn4I>6(9;kps@iMS38KC)CI~e_KSgx*A3NV}cK{B;{ZZT1el(0Y2OQIH{Wp=ZTLsC}(W!QZg zZT`U3*!!FmF@P)zIeIP?>6v0~p*ah0XNYlQ^0i&K#I}x+8s%u^Q__!)WSJXr=GQdN zLE1GQQDv8g*$wQ@*ZZ3pQIZzK7iSsWcXJ8Y52C25dsz$b42VX= zJwoF=C5@ulTbW!U+uS@?F+>X#?wukq+Z-sC%c~#qJ#Dk(0Kxm|M^TX$0SG%_h>p6e zsFn{gl&rypT@y3}$1Xsh522r@8A|!4(y90l#|S{|esK0lTa)*+RMs+zQmWqpqzzL* zlYlN3%7>RC2h=};<>{c$z)6;h^FHh_c#)U>4lR~g$ zgl)aV9}Rkia4qh|UOqK}jJ2P}a$ufndDLftG(yVl`-A#46&syyJ3=(kzL*zm^_1YW z`AgB@hZ*nM2&q4c;DQr;tOP26MZaka?ukhF!}QNJz8f12bMdrOKczD8fM_s}ig@xu zR=o%u%7Dc98j0MlsqWJIx3^Km!|klTaPHWRUScc;w|hr}5EiNGTs`mpp|V;D^Lo)J zk*^p=Y)t53HK5!gg?XzH#H#rlV|HkGC2uZp5%5OCIQcmDPE#QlOiY$;vToZ*Q|LjP zeb4MC*06+%$a^y)=2gO zTu3rA{W|F&sRdQ0D6V{Wtt(>aos+W$aO3A`07s91=-Pje80NuS^h zeiNg*W^LdL3XC&POeIt-{8k9SkKen`s+%RH&VY9i!$|Q~55Sp6BlL@gvC=L0`;bU7 zY+mHbzGP3(95QG6vY4A+d_QEEqALbJXx80}7^8QAM6$xqQO_ z4h{3~GyQj+WuRgp=x_QwCOXIz0yT`zuY&;pOH24<-S)ZcoJN>T5n&3EWHhm2rjTIL z5Q2ys|Cw2kZzM@D;(~LG058d7j{X&lpwB{A$45-4fxQnz5)66Pkj$G%d#pQlBsS3j zwe>BZ<&%J}39V82!XZ>ox(1L7xq(G}7LcgCO9b;i;eaV3%9|nV6)jKbQIrkpM5Mfd z68V!v@NXiFz);d??r&03B(;BInt6-j-vcba6i6?ii(@IrbZTW{0yTFu1$Sx_5A9M0 z8z!Kw!tW{*3!~y>B^~yY#OAUi>y9W;kLn(VFp)xZa>*m0%F;I*mYUmlO2?4XUT6k~ z-UnenQN46qpq*8Dd&qC)=SG?QKn83%n%6*OaGFKm+{w1((F_v(?+h~%X|~oYCKn#X z65Mw010c8V6I`^iAne2>$#+^z>=OhL3CvnlWW(P5gn`JGlH8F0Dtgx8gXI9YU0o=D z0$!aKhlAAwH1a@ZVT@zAqk*F~;a?eQY=qM6Zy*c!VqdmqY3Y9>A^-J(HjgLzD90yQ zytm_jpa?okTPi=~erBw~#Q9RKCFzQ#9kPcHmh~>)gC?p29^X85Ga?Yf3~YiZ!`u41 zK;$u6oN#J)VE~y4@~T`cqP;+x;_q3Z);0r;5A5L%vDf4FfgZ;DtG4@N#MRcW$HfB? z#;Y_g#|CqN8OA#uEwgiWi%0}?-(S#PiO;7)(`PP>|1aTS_?K`Hf3*EeIJi6{d1G1b zH_fo-M_G7Z=F)qmYxn6Od3B!Qno_L`RnjK}>5(h>uYVM0ynqCwk(?)%TtxhbBR=!( z3ExU5KuN1=U z_Z2=Gg$3zz;g15?lcIF(%$s@Px$;a(bgG^!w;wo(1WtA?MNT#jP0h=2Da(2Foz8p9 zI`@;fmcJG5R$t9~BBSxr(<$|x#DmlSaY0^%eQepc4;&gZ3yp6`Z)yQ% zhaZQtD43Tq!uT^yt_tXw<~r_yfYH#^xA}0i9;N zfG;v@f6d?CnbTA{{%t))5Zo0OEZa3 z*twl~lIeUBWOM)@|0YNmz1(jDKw64Lu@@^-PUySK3Vyet-3puVHnOg7m?%>T??8Q! z9IdTOLYO~Ij5q8Wl3X$^05q_EZf5dq_Z#;w%}n-rk}9NSSeuLG@Vq1ts0EOzT%W%@ z|1uCqNu!|HM|?qw;RV=`MxHJWF3ES1AaxS7=q_f@=fvI}AYX>}UUT0G{(tSg1y>wh z(>98`26uN$aF^f~oFGAiySqcM;2PY6y9_SD0)fFbXc!pWHP|=F^PV^NlXHK+;G8{c zW_tGOy1I6+n%>=2wXaIut6J8uci?YMBpO;eT?=)Q8ApQ$=-P047)+xZzgZKno`cEH z0?Up&iJ#RbPJh3)D+<_Xft4mAqRs4vKZ>7>U{rMpALtC`)8`pws)h@)XqsuZ>%8wt1K zkk#WDmI0GiJPgrfMSJe=r8+nyIdeqBQFLMAux&|0SXbLv;;Bgf7y z4VC+!=I`3(6x0sM`Ht7bl5(#81$7kkFzH(f+YdmN4~czESgJwJ_E<2lP8f@c`I=?GZM=SPd%o}j{+8<3&z^$54T$d`#&rN=3t#z6Z9{?rn8c$8s~_RvUP)j);h4hj3eoIblB}l zo18@`M1H4$-OsrUPjkP@b4A9TFt512yU!8n!dAr#;BA`gfu~g&0 z#rPpnFI|5Nh4?HA+>2_{@_JGZp3y{`9NT}UA>0AD9zQQUjlSV7NzfM*U2daVvg+)Z z33p$RA`_l(ZCEW^w9LOo){MSqM;xY_oJbF-Uao15)vNTkB?MG|UgFhXGCtVW4^DL?9$*wR%s7L0JsoyYW zZLJM7(TDiDb2}P$$4|O_K`WRbWQ6zh908p38gQ69bKFK)q%&BUPy2lw8P$P99k_j0?_7ZjOjWulbx9Oa?CZFsl%4e^sR%@-r$?!9fz_lQ+s5e9baY^1;K|4GbCk1 zL*?DiE~wgi5ek(>O>wPS%LBs-Mx$@>@|dm`nKYX2)tjgrMip^MT0{yOX=ezg>JH;@DeB_bxxg-ZoIX#0y<6QLuY0_D8psLKE)T%~j2@U4^TxaGDD5h_8Fmf#>X%%E z=^iJ%{HCDtX}i60{C%_cmoZH+5du)UzjG>MluNx`?o>mRvi3B;sZ@12#+y-V2_ZiR z>W3uuh56Ps@ z;!4Bp$hIPB+2zIp&$IBid;%n`P0qlYRHNcY4Xn5px&#&DG$v`O1 z<#fDP53i6iuBNQ?4(?HnoyKp$8c)PCl5kD40&?18T#{SB$|qNTFE`eW?mqa8?xi5j zM6Lgc&INtWLe`!fxv}bMb}i*Y#VBe)`WE7RI&cq>+!zK-nxqiy)q zFr78}IzZ(=>@|g@lie-IW23E~YBIjNknQA%(aFMJJFn$dPq+CE8J77KDv=YPy^vqO z*_~D@$(w{y|7Lew!Kg+;SLiyeUp~oGzOV6KEpX7K-)gTtQ8`BR3&Zl(_<*?dAS$T0 zRk{f`QU>xw%tavE9m(rS2&x;f!nd!vBj{3LP~ZgseO+L&Q`_7VNZ8<>9z5eFLBPi~hN07yTYaHGc+3?BPS<{h6T;MMvu}o@5}65NC0lA}>9%6| zCt!P4fUH>DqvW}L#JVCJNFOqgMi2@~f( z`MGXZ=Jw_szdv97UWB2$>hPTxx0|BQ6U*&HuZ3<2V;{H0u2es{#cIW&tJr+mR5B`D zj)5l{#y12Sw%vpe)&uZy6?ZYWynkL~0E20X`hEMJ3W{65DP=-gd<4aWz{9QQ#r#Z) zAebK4zV+h-^T+S>f3^uI`@@>xjaT3eh+ee~h8X z&&@)r7cN`yMjMP=H&)E<0|BNBX{U6Wo7aZ%@UV&s+i#pEQwSV+{m#mAh@Jkn+=(o@H3(B=K_k%N z@zjEhEG4yUQR8hTpLU>mSHqXXs`BMAf*JcF2$!=-psf*f+2UaAa*-3R!x0ly^!r`w zK4}0ET6?I8swt1^nN_`r9i~1yZ0(Zck<&5ax#b34S>4IW#_$$Wrxj$o7ZE?NDJ#+O z*Jgy!ZOa11PkY!}ab&usC5&a%FWOCeNBEqUmo0c}=nu{vy2Q1r3FzMsla$AF>94o- zqI2u~(4dfu2pjlcrzpApAWfEri2_IwZK)pebk#3}JfDLr8Md+Af)cg$ z&td5OO6AU-y|R-_cH4|XwBCja8w$uO(bBT(YsthA1Jqh3Z9AW~J9+|t4&5C9@{D?J zyR9xca}RE*fcQo@DP85zyY}1RZ^b$vwri>fUs$= z!K@;^GY_jaN-v~hh#8^3^Uuip3Y z@5UDaWIbWgoqz`fAtaB}C;qL01vZ#d%pLJ2`G-Kg=a1LVg-1_dY2S67?tt=|S)#BG zy`oAy-*(SFQHGS(~e)(6SWIlItzQ&S5l zPrksvMsI$6cRGC;BBVHE(p4KhCqrn|Q0;+Uc^Nhy?Qc^=byNJo%Zawag<~&P!za%H&&s2^)SNXurfhuPo^R&C8v*($8^0X=7!fl~J#zzPs^Ixvr6G z21GVVyjJ8(4oeG1&fMe_x`ItUh;av?luM|zn{p8|6CVMGBb#v(6_>@i44ABT-d(QL z;q_+d#H5LMV%+H zdhFO3Y@r~D3y{Hq+f1fgfY-g7{VFjzPPuhQI{X^5Lz`N}pfltPfu6}@MMaO8&b%25 z(v3A|htp@bR59@cQ;7~LGJYD;IDg^~e3o#)SAf^r+v_D!MpB;rEm8xH2CF6{z-eyw}G(by&${80T zPeD~K)2?~m66^7q5}Fr+ePufUzuI}^pVfL|NP4kqlc(XKJFcH}q>^|;el(b)MX0(N z7`Bz2=h&vZxdJ_CEUa_NZByH+YibOL#~&BiF`%cs@p*?=wLP)s+pC{icQ6ri^!QK^ zn@tFtBeqO%-P*UnHLf+i0X=wkn`IiPBx;%$k}A_DZnpM4ONaMI0hXYfy!3B`yWUh3 zB^dZzFu&c;iRG)GGT=h{a>H(_HOs7!f zVo>Xw(!J)1IP5;0-kKxY^!tMjmXV<}P-aTH5brd@5ujsP#q{Uh{hn3lH223J7h`Td zE!LB+geQd;Gh+|e;C3P2SXNA6#|B~E-k2X`DTVjbg~|+o-yevPvV%aG-I(G1^vL6?(Ck5fBmOw~`KIk%?>#|f`vHj^d zB4AS5l3~h-N6QGt5tJqkFZ2~AxjdsJ2g1A;L0&O&YEM9M69bL|8QQ6Cdv~&&lP>{R1o0HT)BLPu|tXKN{7NTk3eB;->Z|XJ_gpd zzE^ZeMKUaCmLV1#M1jw-QItNi%j&SY2~Qm`-gYe|3oIyRN_-ixKtG+JMlEpSS_yhc z(l2TMU}yb#U~dHC=Z*4cFov`7t(wjC2+1Ef=AlE*)_BXsY03axm^-pKBgqz8Gu0vG zeWN0X?8mEJP8A4ZbC#Av=VyjXI`IjJnoUnM?hKbsFO_j$)jNJq)5ANtm8lj)_kfzFY4Fl;i_kWDZb;P?wPSWJpwIXa3-uW~WNr|jN-wlp z>LaFB7Yt&Wo$@KF0!D!!WuLCxc2kKle z>B(C%hKel|+`KWMcC70HMy+hD-++J>yB-*cKSF$iGzHGpVe*9*e6)%Mkm(&|JH1O$ z%U6G?D}J9~D0oC56&63Dd0#e(b`D8dqDKC$*-mz4Hue5!>SpXPQn?Jq(n56K>zO_) zyAc-xJc~90#9Hj)V0B7Raw4s>)1$d#HKh4edsSmnMj?@jl+R}8h zD|5Sq?akWv8}=RBBcr&Dsi~ro<;sqQa>lR7%*j;n6}F5m^;#JyLJMJq%e5j;t$E{N zD3nv;eD3)ed0oS;6t-}t6;oT}NFsx(ta+q!C0McMw!EZzjB$8oEQ!!7gZ+Yvf}aF0 zgTOAp(KdOZuhDa?zz49ZgU^^!8G7Gqt>@pzPCA6YBQ*R}V2W@t~y+b2kS zFuJgssSy|}MhAInM)WGacu@T8lG{ypUw7H;-n@Mtug~##toP^j6OVbPp%;@TFYNB+|3yU zN%xkne7m|YxPH_gJ&+Jq(~UKEaY!RYVF?P~jN&Lx7v3=A7L}$5porMxm>CpPU?S7A zlPRBI9TKH;ah~aEAjuHC{f<{5a}K@q70kSUyY|81t4Hu2A}7*}V{An|O3itZz0=Dc z3BKr@3!5!PZMUKn;q(q@4!)<%@%8NFji>C)Y7BH4D!lW8a5=Z8&Vaz7=ScpSfK zatRIJmlIdGpK1aPX$6|@NX*xbBoUL1|j}VSV$oT zEGQ&sGspL;E{;yF941aqzvep1LO5u~d??5s|KD!e$;yu3U!sMdz+O|Jt>d(? zq3kYcZxp=UMO8Q!*OwJd8v%C>DMXhmae|4j*mVTUl%n_4YIrnTLD&^R%!RnaVV%;u z^8gr==D*8zHq_2z_NHF~0@g#=)Jnq+E#b#3I3!z$y z&^Y35IhoVq*x1lq!ZNuVspZnLDxFd zxk&R!IOh?+lN}WBlc6V1juVvg?y+#qqYSFr=dMK>Zd^oJawt=@sf_&>S%{oINdBMS_0cDg*^I9d1e_iPe)+}j-= z_LSwo7V9c@aU;F`iAOM!HjGHV2pfya-gy|F$$owS87*BvzX7%)S_*FEco(T#J<~Wr5w8MO1X@ zC~l=oWkTaJ7mb{i6?3d$KFNT_H2V0k zoV_0OfB*tW1+Y-Q`T=$yP%K8VDrSCBWGvpIcA}+l83Vl}!*>4F{1bEGtFlNvdu{Wy z1$nOcFS?1M8uF&fy@^gN_&4gFxKs> zg6H@Dblfp@BzL7J;#KXG9+G%S%V^hSHp-ke9t5devQ-H6!~-^1l~K(dJ`Py6QdQC^ zmJ_9{jCe$Sx>6aQl?^Z3v}Cj+yAfQF&0x(C%|4(lh_eUV1sw)eO-}P9C{mJ83Q-ae zZhus7wKugeP79`oy->HZGd^E2eBWT1EN$`5!q_lcI<^7WOAVX;a>Rs#%gNI)0Z_Ys zv+8YKOS66NQS9d$m$Hc076JD4>K2>GJ(*|(-(MWIE#;<*n4`}hVv1WX&7oHMap3fy zGrggdTA5mi!}fIR5sJ894Mv!HOzUpBZ2nMt&+oP@KA`R>N6JVxV!bx3ZvEI0t2LCr zN)^c#XYOFCvvUu}jQWk1+RuK^mZb7*0IU1DzU5Aw>t1B_WG`R>xU_vzw&aXoKYpig z>v8wds^zqEn*e%3-)rs51$pkxX=emjMEGR0t#5dp`}U_1WsG`g^y!x`o-3y~`?mr> zWcP&GR1G>h~I2t;5=dotWbRr zGINSJcOmdp<0%mecf8B7_Hd$omrTU8vX-M6&F z2s3Z7-{`#?CZzF%xOa(YZsa3!grRCyZV^bvo)COP_-S-Ml6dW;1=)(E`^=`JSG9nkT7u(?jud}o@5zG?w66}((@*-qob1#G;o6IM5I0ao> zfjrk^;}ou`k2i`zf*kIqZg~(r>xwx6J>e1hO^w|5R&aT)Cqy5&gY7%eeyMNW=u%Pp z0sZJBs9DQX8t-L?y+=FEpY7Uyk*Ysg5a3ys&Nd&6&(M#L*pGkJ zAzg*flj^%jR5*d(kLN~T%toA>M4ufEnvhqH0oC7OIp?fkU`LUt4n zhvg&<-d$bPi+;5|kUwpo-Ly;1d(sp(gF9AM*M|%%1fi8ih3bY_z<7MPAuHVe^n&q{kI6!>& zA?Sp}klhel4@VEC9sV^K(Qo~<;Vg49a}s5e4NI`pG0JYgDHW@fTKz=REOws`Jytik zQRXUXaj^P)JQ6oAl_n>8J0|rA;b4&`fyGe6@Z#rXbV3*tPp}2@JOn^&<31d4{5EVp zEG@_(c=8TaGu5@^j+w{%tIB974@p<_ia)MRAX3UHsm8h7n40;zl zZO3!l;w1us0)x)dhVJ$Vdm@7ciwG(@+w>kVsq%us3eSYJ23eBz6M5oJwdrNZsK)>$ zt$4L$3mPqv0wP5)S*Y8_D>=&~ySs!}g+N$QLc5~tLmYhdx$fnQ zFMN1(y#j|->fJdS_yLZnRj)9TECVQ4*>_R?p8-$3rB{!b#eVn+p}PerZY)jQ z9;M`DUBp5vTXJW7!3l|)K0`?g6OBDz5tnnGbZ{N9n6B|LL zXa+eZM;goL?S%Fr?1jIdF3s+IM@yTXO;{))2&JSWr!|cJe$S3;g#6gu{5|U)8Uq#@ z9YJ1J^DXzGEl23li+VnDK1$KiFx&^J)f?6a#-1Y2@><{Q7`HweBd&C zrTxmv5+kfY-Cm>+FA0Z^JfhXnYd34kYJ&pDI=>(}SZgkn+$-iSq8$MavV4GuYccGl z_QrP!$5UKJ|Dthxoioj{bTW#*cj6_Amu-;0I-Squ*rv5ctsuF`Tc}*o64)lcAO1r> ziN2CY8b;W`Nq*SKz0i?6vts*@YM8O&YG@58$Ue>HlFd}gim)2A@5JzCoyB)5cD&R! zW9c$#0}Frtu4?SX!YQlp#!)&Bk3)|ad(<{%5GY>8#^z!XwmkjALPpqGcd>JF80W3I zoV$gbRcv;$W&P!Q;0TxEC^y(i2w|ci;$`LJOTriJ5?~Np+@)PA4Vj*Fae&)|cT>p_ zccrSBw$v!M?D-1#l^*kq4PA-3ba7MDF8{KkwRJ#m;`Ou$SbznuW_YwCRJ19boW-?x zu}P(&0Cek-W56{aw`jKN~f5ev&w zj$VDVAs4$h<=Rm^bg7d;!(*{6M*^~+NL7y3cC_A+)6f%`PSKXC-NZ}W|5^ktkx)>) zAa!h?N1;?t@NooXmk>0gZOWoBkdPe)mRwvujU0S%%l)O+$8(*wmR-I8=F(k|xuA3a^Q686^usXvE5;?Ja_6&=bc64*QB3n{|=ma7)Np zY9-atmKH%Hq{JErHDi(MUmBf9(2#vaR^PGG9bUPqsS0ce%re6k5OV@bQogHPrfk-V zcjmsOG@M|;ss-;972Ak%VsWhRz|srEDHaLmfH7w@XTr z>hSlS@u*B?Lh_aew)OZP)7|Y;5})8SZ7Se1qPzwL7e_m{u}rq;-7A8K6lrNkE9b2H=2HIXWzCk?wE1`q>Ij%nlTtRtF40zq>D#qwS|gB2i$19EwDRnWlQ{vy591~$CW(HTQ3zJCv&9nR?X!1 zf%~bE&=8=IAU#x2?RJYV zQXqEt0QvbV_u{{szNDjro4JFVk*2qkxvRl1yHr*DZvg)>&0ItXz$(O$QU6PN92N@7 z$i>{wm4p4)=ih?GbZmVh5J56Xl|)G5$3Gf8qz6L5`5#$NM;BXDM@QRV$NpCw`j5ffS&Q}+E4C4-dB{Ke1uH-X>Z2!Au%{XyXO|JNb>=DGVD zeZ8U;hUb(Dl6l literal 0 HcmV?d00001 From 426c108677ce6baaa952dbb39314aa853150d73b Mon Sep 17 00:00:00 2001 From: janezd Date: Mon, 10 Jul 2017 11:26:59 +0200 Subject: [PATCH 03/27] distance: Implement Cosine distance --- Orange/distance/__init__.py | 80 +- Orange/distance/_distance.c | 5561 +++++++++++++++++------- Orange/distance/_distance.pyx | 249 +- Orange/distance/distances.md | 43 +- Orange/distance/tests/calculation.xlsx | Bin 52794 -> 66630 bytes Orange/distance/tests/test_distance.py | 554 ++- 6 files changed, 4510 insertions(+), 1977 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index d02855e1ec5..33a0d9c9adb 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -104,7 +104,10 @@ def compute_distances(self, x1, x2=None): return self.distance_by_cols(x1, self.fit_params) else: return self.distance_by_rows( - x1, x2 if x2 is not None else x1, self.fit_params) + x1, + x2 if x2 is not None else x1, + x2 is not None, + self.fit_params) class FittedDistance(Distance): @@ -121,6 +124,13 @@ def fit(self, data): # pylint: disable=not-callable return self.ModelType(attributes, axis=self.axis, fit_params=fit_params) + def fit_cols(self, x, n_vals): + if any(n_vals): + raise ValueError("columns with discrete values are incommensurable") + + def fit_rows(self, x, n_vals): + pass + class EuclideanModel(FittedDistanceModel): name = "Euclidean" @@ -137,6 +147,7 @@ def __new__(cls, *args, **kwargs): return super().__new__(cls, *args, **kwargs) def fit_rows(self, x, n_vals): + super().fit_rows(x, n_vals) n_cols = len(n_vals) n_bins = max(n_vals) means = np.zeros(n_cols, dtype=float) @@ -171,9 +182,7 @@ def fit_rows(self, x, n_vals): normalize=int(self.normalize)) def fit_cols(self, x, n_vals): - if any(n_vals): - raise ValueError( - "columns with discrete values are not commensurate") + super().fit_cols(x, n_vals) means = np.nanmean(x, axis=0) vars = np.nanvar(x, axis=0) if np.isnan(vars).any() or not vars.all(): @@ -196,6 +205,7 @@ def __new__(cls, *args, **kwargs): return super().__new__(cls, *args, **kwargs) def fit_rows(self, x, n_vals): + super().fit_rows(x, n_vals) n_cols = len(n_vals) n_bins = max(n_vals) @@ -227,9 +237,7 @@ def fit_rows(self, x, n_vals): normalize=int(self.normalize)) def fit_cols(self, x, n_vals): - if any(n_vals): - raise ValueError( - "columns with discrete values are not commensurate") + super().fit_cols(x, n_vals) medians = np.nanmedian(x, axis=0) mads = np.nanmedian(np.abs(x - medians), axis=0) if np.isnan(mads).any() or not mads.all(): @@ -239,6 +247,49 @@ def fit_cols(self, x, n_vals): return dict(medians=medians, mads=mads, normalize=int(self.normalize)) +class CosineModel(FittedDistanceModel): + supports_sparse = False + distance_by_rows = _distance.cosine_rows + distance_by_cols = _distance.cosine_cols + + +class Cosine(FittedDistance): + ModelType = CosineModel + + def __new__(cls, *args, **kwargs): + kwargs.setdefault("normalize", False) + return super().__new__(cls, *args, **kwargs) + + def fit_rows(self, x, n_vals): + super().fit_rows(x, n_vals) + n, n_cols = x.shape + means = np.zeros(n_cols, dtype=float) + vars = np.empty(n_cols, dtype=float) + dist_missing2 = np.zeros(n_cols, dtype=float) + + for col in range(n_cols): + column = x[:, col] + if n_vals[col]: + vars[col] = -1 + nonnans = n - np.sum(np.isnan(column)) + means[col] = 1 - np.sum(column == 0) / nonnans + dist_missing2[col] = means[col] + elif np.isnan(column).all(): # avoid warnings in nanmean and nanvar + vars[col] = -2 + else: + means[col] = util.nanmean(column) + vars[col] = util.nanvar(column) + if vars[col] == 0: + vars[col] = -2 + dist_missing2[col] = means[col] ** 2 + if np.isnan(dist_missing2[col]): + dist_missing2[col] = 0 + + return dict(means=means, vars=vars, dist_missing2=dist_missing2) + + fit_cols = fit_rows + + class JaccardModel(FittedDistanceModel): supports_sparse = False distance_by_cols = _distance.jaccard_cols @@ -248,17 +299,14 @@ class JaccardModel(FittedDistanceModel): class Jaccard(FittedDistance): ModelType = JaccardModel name = "Jaccard" - fit_rows = fit_cols = _distance.fit_jaccard - - -class CosineModel(EuclideanModel): - def compute_distances(self, x1, x2=None): - return 1 - np.cos(1 - super().compute_distances(x1, x2)) + def fit_rows(self, x, n_vals): + return { + "ps": np.fromiter( + (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), + dtype=np.double, count=len(n_vals))} -class Cosine(Euclidean): - ModelType = CosineModel - name = "Cosine" + fit_cols = fit_rows class SpearmanDistance(Distance): diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index 9d1c7bbd99b..f07148cd1c9 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -1160,6 +1160,11 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); @@ -1180,6 +1185,13 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* BufferFallbackError.proto */ +static void __Pyx_RaiseBufferFallbackError(void); + /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { @@ -1210,9 +1222,6 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - /* IncludeStringH.proto */ #include @@ -1368,11 +1377,6 @@ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); #define __PYX_FORCE_INIT_THREADS 0 #endif -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); @@ -1555,10 +1559,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, int dtype_is_object); /* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); /* CIntFromPy.proto */ -static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); @@ -1659,7 +1663,9 @@ static PyObject *contiguous = 0; static PyObject *indirect_contiguous = 0; static int __pyx_memoryview_thread_locks_used; static PyThread_type_lock __pyx_memoryview_thread_locks[8]; -static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice); /*proto*/ +static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice); /*proto*/ +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); /*proto*/ +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); /*proto*/ static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ static void *__pyx_align_pointer(void *, size_t); /*proto*/ static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ @@ -1716,12 +1722,14 @@ static const char __pyx_k_np[] = "np"; static const char __pyx_k_ps[] = "ps"; static const char __pyx_k_x1[] = "x1"; static const char __pyx_k_x2[] = "x2"; -static const char __pyx_k__29[] = "_"; static const char __pyx_k_all[] = "all"; static const char __pyx_k_col[] = "col"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_row[] = "row"; static const char __pyx_k_val[] = "val"; +static const char __pyx_k_abs1[] = "abs1"; +static const char __pyx_k_abs2[] = "abs2"; +static const char __pyx_k_abss[] = "abss"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_col1[] = "col1"; static const char __pyx_k_col2[] = "col2"; @@ -1734,7 +1742,6 @@ static const char __pyx_k_ones[] = "ones"; static const char __pyx_k_pack[] = "pack"; static const char __pyx_k_row1[] = "row1"; static const char __pyx_k_row2[] = "row2"; -static const char __pyx_k_same[] = "same"; static const char __pyx_k_size[] = "size"; static const char __pyx_k_sqrt[] = "sqrt"; static const char __pyx_k_step[] = "step"; @@ -1759,7 +1766,6 @@ static const char __pyx_k_shape[] = "shape"; static const char __pyx_k_start[] = "start"; static const char __pyx_k_union[] = "union"; static const char __pyx_k_zeros[] = "zeros"; -static const char __pyx_k_double[] = "double"; static const char __pyx_k_encode[] = "encode"; static const char __pyx_k_format[] = "format"; static const char __pyx_k_import[] = "__import__"; @@ -1786,14 +1792,17 @@ static const char __pyx_k_distances[] = "distances"; static const char __pyx_k_enumerate[] = "enumerate"; static const char __pyx_k_normalize[] = "normalize"; static const char __pyx_k_not1_unk2[] = "not1_unk2"; +static const char __pyx_k_p_nonzero[] = "p_nonzero"; static const char __pyx_k_unk1_not2[] = "unk1_not2"; static const char __pyx_k_unk1_unk2[] = "unk1_unk2"; static const char __pyx_k_IndexError[] = "IndexError"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_fit_params[] = "fit_params"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_two_tables[] = "two_tables"; static const char __pyx_k_MemoryError[] = "MemoryError"; -static const char __pyx_k_fit_jaccard[] = "fit_jaccard"; +static const char __pyx_k_cosine_cols[] = "cosine_cols"; +static const char __pyx_k_cosine_rows[] = "cosine_rows"; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_dist_missing[] = "dist_missing"; static const char __pyx_k_intersection[] = "intersection"; @@ -1860,7 +1869,9 @@ static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; static PyObject *__pyx_kp_s_Users_janez_Dropbox_orange3_Ora; static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_n_s__29; +static PyObject *__pyx_n_s_abs1; +static PyObject *__pyx_n_s_abs2; +static PyObject *__pyx_n_s_abss; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_allocate_buffer; static PyObject *__pyx_n_s_base; @@ -1873,11 +1884,12 @@ static PyObject *__pyx_n_s_col1; static PyObject *__pyx_n_s_col2; static PyObject *__pyx_kp_s_contiguous_and_direct; static PyObject *__pyx_kp_s_contiguous_and_indirect; +static PyObject *__pyx_n_s_cosine_cols; +static PyObject *__pyx_n_s_cosine_rows; static PyObject *__pyx_n_s_d; static PyObject *__pyx_n_s_dist_missing; static PyObject *__pyx_n_s_dist_missing2; static PyObject *__pyx_n_s_distances; -static PyObject *__pyx_n_s_double; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dtype_is_object; static PyObject *__pyx_n_s_empty; @@ -1886,7 +1898,6 @@ static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_euclidean_cols; static PyObject *__pyx_n_s_euclidean_rows; -static PyObject *__pyx_n_s_fit_jaccard; static PyObject *__pyx_n_s_fit_params; static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_format; @@ -1931,6 +1942,7 @@ static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_obj; static PyObject *__pyx_n_s_ones; +static PyObject *__pyx_n_s_p_nonzero; static PyObject *__pyx_n_s_pack; static PyObject *__pyx_n_s_ps; static PyObject *__pyx_n_s_pyx_getbuffer; @@ -1939,7 +1951,6 @@ static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_row; static PyObject *__pyx_n_s_row1; static PyObject *__pyx_n_s_row2; -static PyObject *__pyx_n_s_same; static PyObject *__pyx_n_s_shape; static PyObject *__pyx_n_s_size; static PyObject *__pyx_n_s_sqrt; @@ -1951,6 +1962,7 @@ static PyObject *__pyx_kp_s_strided_and_direct_or_indirect; static PyObject *__pyx_kp_s_strided_and_indirect; static PyObject *__pyx_n_s_struct; static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_two_tables; static PyObject *__pyx_kp_s_unable_to_allocate_array_data; static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str; static PyObject *__pyx_n_s_union; @@ -1967,13 +1979,15 @@ static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_x1; static PyObject *__pyx_n_s_x2; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, CYTHON_UNUSED PyObject *__pyx_v__); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ @@ -2012,21 +2026,22 @@ static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_float_1_0; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; +static PyObject *__pyx_slice__2; +static PyObject *__pyx_slice__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; -static PyObject *__pyx_slice__17; -static PyObject *__pyx_slice__18; static PyObject *__pyx_slice__19; +static PyObject *__pyx_slice__20; +static PyObject *__pyx_slice__21; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; @@ -2034,38 +2049,43 @@ static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; static PyObject *__pyx_tuple__16; -static PyObject *__pyx_tuple__20; -static PyObject *__pyx_tuple__21; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__23; static PyObject *__pyx_tuple__25; static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__30; -static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__34; -static PyObject *__pyx_tuple__36; +static PyObject *__pyx_tuple__29; +static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_tuple__35; static PyObject *__pyx_tuple__37; -static PyObject *__pyx_tuple__38; static PyObject *__pyx_tuple__39; -static PyObject *__pyx_tuple__40; -static PyObject *__pyx_codeobj__22; +static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__42; +static PyObject *__pyx_tuple__43; +static PyObject *__pyx_tuple__44; +static PyObject *__pyx_tuple__45; static PyObject *__pyx_codeobj__24; static PyObject *__pyx_codeobj__26; static PyObject *__pyx_codeobj__28; -static PyObject *__pyx_codeobj__31; -static PyObject *__pyx_codeobj__33; -static PyObject *__pyx_codeobj__35; +static PyObject *__pyx_codeobj__30; +static PyObject *__pyx_codeobj__32; +static PyObject *__pyx_codeobj__34; +static PyObject *__pyx_codeobj__36; +static PyObject *__pyx_codeobj__38; +static PyObject *__pyx_codeobj__40; -/* "Orange/distance/_distance.pyx":19 +/* "Orange/distance/_distance.pyx":20 * * # This function is unused, but kept here for any future use - * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< + * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< * cdef int col * for col in range(dividers.shape[0]): */ -static PyObject *__pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_dividers) { +static void __pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_dividers) { int __pyx_v_col; - PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; int __pyx_t_2; @@ -2080,8 +2100,8 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__ int __pyx_t_11; __Pyx_RefNannySetupContext("_check_division_by_zero", 0); - /* "Orange/distance/_distance.pyx":21 - * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): + /* "Orange/distance/_distance.pyx":22 + * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): * cdef int col * for col in range(dividers.shape[0]): # <<<<<<<<<<<<<< * if dividers[col] == 0 and not x[:, col].isnan().all(): @@ -2091,7 +2111,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_col = __pyx_t_2; - /* "Orange/distance/_distance.pyx":22 + /* "Orange/distance/_distance.pyx":23 * cdef int col * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< @@ -2120,15 +2140,15 @@ __pyx_t_8.strides[0] = __pyx_v_x.strides[0]; __pyx_tmp_idx += __pyx_tmp_shape; if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) { PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)"); - __PYX_ERR(0, 22, __pyx_L1_error) + __PYX_ERR(0, 23, __pyx_L1_error) } __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride; } -__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 22, __pyx_L1_error) +__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; @@ -2142,14 +2162,14 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } if (__pyx_t_9) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { - __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; @@ -2163,34 +2183,34 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } if (__pyx_t_7) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_11 = ((!__pyx_t_5) != 0); __pyx_t_3 = __pyx_t_11; __pyx_L6_bool_binop_done:; if (__pyx_t_3) { - /* "Orange/distance/_distance.pyx":23 + /* "Orange/distance/_distance.pyx":24 * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< * * */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 23, __pyx_L1_error) + __PYX_ERR(0, 24, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":22 + /* "Orange/distance/_distance.pyx":23 * cdef int col * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< @@ -2200,16 +2220,15 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } - /* "Orange/distance/_distance.pyx":19 + /* "Orange/distance/_distance.pyx":20 * * # This function is unused, but kept here for any future use - * cdef _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< + * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< * cdef int col * for col in range(dividers.shape[0]): */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); @@ -2217,26 +2236,22 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("Orange.distance._distance._check_division_by_zero", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __Pyx_WriteUnraisable("Orange.distance._distance._check_division_by_zero", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -/* "Orange/distance/_distance.pyx":26 +/* "Orange/distance/_distance.pyx":27 * * - * cdef _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< * cdef int row1, row2 * for row1 in range(distances.shape[0]): */ -static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice __pyx_v_distances) { +static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice __pyx_v_distances) { int __pyx_v_row1; int __pyx_v_row2; - PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; int __pyx_t_2; @@ -2248,8 +2263,8 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_ Py_ssize_t __pyx_t_8; __Pyx_RefNannySetupContext("_lower_to_symmetric", 0); - /* "Orange/distance/_distance.pyx":28 - * cdef _lower_to_symmetric(double [:, :] distances): + /* "Orange/distance/_distance.pyx":29 + * cdef void _lower_to_symmetric(double [:, :] distances): * cdef int row1, row2 * for row1 in range(distances.shape[0]): # <<<<<<<<<<<<<< * for row2 in range(row1): @@ -2259,7 +2274,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row1 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":29 + /* "Orange/distance/_distance.pyx":30 * cdef int row1, row2 * for row1 in range(distances.shape[0]): * for row2 in range(row1): # <<<<<<<<<<<<<< @@ -2270,7 +2285,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_ for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row2 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":30 + /* "Orange/distance/_distance.pyx":31 * for row1 in range(distances.shape[0]): * for row2 in range(row1): * distances[row2, row1] = distances[row1, row2] # <<<<<<<<<<<<<< @@ -2285,47 +2300,46 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_ } } - /* "Orange/distance/_distance.pyx":26 + /* "Orange/distance/_distance.pyx":27 * * - * cdef _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< * cdef int row1, row2 * for row1 in range(distances.shape[0]): */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -/* "Orange/distance/_distance.pyx":33 +/* "Orange/distance/_distance.pyx":34 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ /* Python wrapper */ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows[] = "euclidean_rows(ndarray x1, ndarray x2, fit_params)"; +static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows[] = "euclidean_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows = {"euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_euclidean_rows}; static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("euclidean_rows (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; - PyObject* values[3] = {0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -2340,39 +2354,46 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, 1); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 1); __PYX_ERR(0, 34, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 2); __PYX_ERR(0, 34, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, 2); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 3); __PYX_ERR(0, 34, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 33, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 34, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_fit_params = values[2]; + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error) + __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 34, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 33, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 34, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 34, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 35, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ goto __pyx_L0; @@ -2383,7 +2404,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; @@ -2401,7 +2422,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU int __pyx_v_ival1; int __pyx_v_ival2; __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_same; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; @@ -2412,9 +2432,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; char __pyx_t_4; - int __pyx_t_5; + npy_intp __pyx_t_5; npy_intp __pyx_t_6; - npy_intp __pyx_t_7; + int __pyx_t_7; Py_ssize_t __pyx_t_8; Py_ssize_t __pyx_t_9; Py_ssize_t __pyx_t_10; @@ -2465,115 +2485,105 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 34, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 34, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":37 + /* "Orange/distance/_distance.pyx":39 * fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 37, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":38 + /* "Orange/distance/_distance.pyx":40 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 38, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":39 + /* "Orange/distance/_distance.pyx":41 * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 39, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":40 + /* "Orange/distance/_distance.pyx":42 * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 40, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":41 + /* "Orange/distance/_distance.pyx":43 * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_4; - /* "Orange/distance/_distance.pyx":47 - * int ival1, ival2 + /* "Orange/distance/_distance.pyx":50 * double [:, :] distances - * char same = x1 is x2 # <<<<<<<<<<<<<< - * - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - */ - __pyx_t_5 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); - __pyx_v_same = __pyx_t_5; - - /* "Orange/distance/_distance.pyx":49 - * char same = x1 is x2 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ */ - __pyx_t_6 = (__pyx_v_x1->dimensions[0]); - __pyx_t_7 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_6; - __pyx_v_n_cols = __pyx_t_7; + __pyx_t_5 = (__pyx_v_x1->dimensions[0]); + __pyx_t_6 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_5; + __pyx_v_n_cols = __pyx_t_6; - /* "Orange/distance/_distance.pyx":50 + /* "Orange/distance/_distance.pyx":51 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -2582,7 +2592,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":51 + /* "Orange/distance/_distance.pyx":52 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -2591,75 +2601,75 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_8 == __pyx_t_9); - if (__pyx_t_5) { + __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":52 + /* "Orange/distance/_distance.pyx":53 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< * distances = np.zeros((n_rows1, n_rows2), dtype=float) * */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_9 == __pyx_t_10); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_10 == __pyx_t_11); + __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); } } } } - /* "Orange/distance/_distance.pyx":51 + /* "Orange/distance/_distance.pyx":52 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< * == len(dist_missing) == len(dist_missing2) * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - if (unlikely(!(__pyx_t_5 != 0))) { + if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 51, __pyx_L1_error) + __PYX_ERR(0, 52, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":53 + /* "Orange/distance/_distance.pyx":54 * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing) == len(dist_missing2) * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * * with nogil: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); @@ -2667,32 +2677,32 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); __pyx_t_1 = 0; __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 53, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 53, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":55 + /* "Orange/distance/_distance.pyx":56 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): */ { #ifdef WITH_THREAD @@ -2701,43 +2711,43 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":56 + /* "Orange/distance/_distance.pyx":57 * * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 */ __pyx_t_15 = __pyx_v_n_rows1; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":57 + /* "Orange/distance/_distance.pyx":58 * with nogil: * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< * d = 0 * for col in range(n_cols): */ - if ((__pyx_v_same != 0)) { - __pyx_t_17 = __pyx_v_row1; - } else { + if ((__pyx_v_two_tables != 0)) { __pyx_t_17 = __pyx_v_n_rows2; + } else { + __pyx_t_17 = __pyx_v_row1; } for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_row2 = __pyx_t_18; - /* "Orange/distance/_distance.pyx":58 + /* "Orange/distance/_distance.pyx":59 * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): * if vars[col] == -2: */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":59 - * for row2 in range(row1 if same else n_rows2): + /* "Orange/distance/_distance.pyx":60 + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< * if vars[col] == -2: @@ -2747,7 +2757,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":60 + /* "Orange/distance/_distance.pyx":61 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -2755,10 +2765,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU * val1, val2 = x1[row1, col], x2[row2, col] */ __pyx_t_21 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":61 + /* "Orange/distance/_distance.pyx":62 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -2767,7 +2777,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":60 + /* "Orange/distance/_distance.pyx":61 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -2776,7 +2786,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":62 + /* "Orange/distance/_distance.pyx":63 * if vars[col] == -2: * continue * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -2792,7 +2802,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_v_val1 = __pyx_t_24; __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":63 + /* "Orange/distance/_distance.pyx":64 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2802,15 +2812,15 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_28) { } else { - __pyx_t_5 = __pyx_t_28; + __pyx_t_7 = __pyx_t_28; goto __pyx_L14_bool_binop_done; } __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_5 = __pyx_t_28; + __pyx_t_7 = __pyx_t_28; __pyx_L14_bool_binop_done:; - if (__pyx_t_5) { + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":64 + /* "Orange/distance/_distance.pyx":65 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -2820,7 +2830,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_29 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":63 + /* "Orange/distance/_distance.pyx":64 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2830,7 +2840,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":65 + /* "Orange/distance/_distance.pyx":66 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -2838,10 +2848,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU * if npy_isnan(val1): */ __pyx_t_30 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_30 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_30 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":66 + /* "Orange/distance/_distance.pyx":67 * d += dist_missing2[col] * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< @@ -2851,17 +2861,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_v_ival1 = ((int)__pyx_v_val1); __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":67 + /* "Orange/distance/_distance.pyx":68 * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< * d += dist_missing[col, ival2] * elif npy_isnan(val2): */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":68 + /* "Orange/distance/_distance.pyx":69 * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< @@ -2872,7 +2882,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_32 = __pyx_v_ival2; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":67 + /* "Orange/distance/_distance.pyx":68 * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -2882,17 +2892,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":69 + /* "Orange/distance/_distance.pyx":70 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += dist_missing[col, ival1] * elif ival1 != ival2: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":70 + /* "Orange/distance/_distance.pyx":71 * d += dist_missing[col, ival2] * elif npy_isnan(val2): * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< @@ -2903,7 +2913,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_34 = __pyx_v_ival1; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":69 + /* "Orange/distance/_distance.pyx":70 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2913,17 +2923,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":71 + /* "Orange/distance/_distance.pyx":72 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< * d += 1 * elif normalize: */ - __pyx_t_5 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":72 + /* "Orange/distance/_distance.pyx":73 * d += dist_missing[col, ival1] * elif ival1 != ival2: * d += 1 # <<<<<<<<<<<<<< @@ -2932,7 +2942,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":71 + /* "Orange/distance/_distance.pyx":72 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -2942,7 +2952,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } __pyx_L16:; - /* "Orange/distance/_distance.pyx":65 + /* "Orange/distance/_distance.pyx":66 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -2952,27 +2962,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":73 + /* "Orange/distance/_distance.pyx":74 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 */ - __pyx_t_5 = (__pyx_v_normalize != 0); - if (__pyx_t_5) { + __pyx_t_7 = (__pyx_v_normalize != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":74 + /* "Orange/distance/_distance.pyx":75 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":75 + /* "Orange/distance/_distance.pyx":76 * elif normalize: * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -2983,7 +2993,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_36 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_35 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_36 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":74 + /* "Orange/distance/_distance.pyx":75 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -2993,17 +3003,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L17; } - /* "Orange/distance/_distance.pyx":76 + /* "Orange/distance/_distance.pyx":77 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":77 + /* "Orange/distance/_distance.pyx":78 * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -3014,7 +3024,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_38 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_37 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_38 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":76 + /* "Orange/distance/_distance.pyx":77 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3024,7 +3034,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L17; } - /* "Orange/distance/_distance.pyx":79 + /* "Orange/distance/_distance.pyx":80 * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 * else: * d += ((val1 - val2) ** 2 / vars[col]) / 2 # <<<<<<<<<<<<<< @@ -3037,7 +3047,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } __pyx_L17:; - /* "Orange/distance/_distance.pyx":73 + /* "Orange/distance/_distance.pyx":74 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -3047,7 +3057,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":81 + /* "Orange/distance/_distance.pyx":82 * d += ((val1 - val2) ** 2 / vars[col]) / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3055,10 +3065,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU * elif npy_isnan(val2): */ /*else*/ { - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":82 + /* "Orange/distance/_distance.pyx":83 * else: * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3069,7 +3079,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_41 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_40 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_41 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":81 + /* "Orange/distance/_distance.pyx":82 * d += ((val1 - val2) ** 2 / vars[col]) / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3079,17 +3089,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L18; } - /* "Orange/distance/_distance.pyx":83 + /* "Orange/distance/_distance.pyx":84 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += (val1 - means[col]) ** 2 + vars[col] * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":84 + /* "Orange/distance/_distance.pyx":85 * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3100,7 +3110,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_43 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_42 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_43 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":83 + /* "Orange/distance/_distance.pyx":84 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3110,12 +3120,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L18; } - /* "Orange/distance/_distance.pyx":86 + /* "Orange/distance/_distance.pyx":87 * d += (val1 - means[col]) ** 2 + vars[col] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< * distances[row1, row2] = d - * if same: + * if not two_tables: */ /*else*/ { __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); @@ -3126,11 +3136,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_L10_continue:; } - /* "Orange/distance/_distance.pyx":87 + /* "Orange/distance/_distance.pyx":88 * else: * d += (val1 - val2) ** 2 * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if same: + * if not two_tables: * _lower_to_symmetric(distances) */ __pyx_t_44 = __pyx_v_row1; @@ -3140,12 +3150,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":55 + /* "Orange/distance/_distance.pyx":56 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): */ /*finally:*/ { /*normal exit:*/{ @@ -3158,50 +3168,48 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":88 + /* "Orange/distance/_distance.pyx":89 * d += (val1 - val2) ** 2 * distances[row1, row2] = d - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return np.sqrt(distances) */ - __pyx_t_5 = (__pyx_v_same != 0); - if (__pyx_t_5) { + __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":89 + /* "Orange/distance/_distance.pyx":90 * distances[row1, row2] = d - * if same: + * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return np.sqrt(distances) * */ - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":88 + /* "Orange/distance/_distance.pyx":89 * d += (val1 - val2) ** 2 * distances[row1, row2] = d - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return np.sqrt(distances) */ } - /* "Orange/distance/_distance.pyx":90 - * if same: + /* "Orange/distance/_distance.pyx":91 + * if not two_tables: * _lower_to_symmetric(distances) * return np.sqrt(distances) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_12 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { @@ -3214,17 +3222,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } if (!__pyx_t_12) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_46); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_46, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_46, 0+1, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0; } @@ -3233,12 +3241,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":33 + /* "Orange/distance/_distance.pyx":34 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ /* function exit code */ @@ -3274,7 +3282,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":93 +/* "Orange/distance/_distance.pyx":94 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -3312,11 +3320,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 93, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 94, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 93, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 94, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3329,13 +3337,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 93, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 94, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 93, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 94, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -3410,56 +3418,56 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 93, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":95 + /* "Orange/distance/_distance.pyx":96 * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:] vars = fit_params["vars"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 95, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":96 + /* "Orange/distance/_distance.pyx":97 * cdef: * double [:] means = fit_params["means"] * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":97 + /* "Orange/distance/_distance.pyx":98 * double [:] means = fit_params["means"] * double [:] vars = fit_params["vars"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_3; - /* "Orange/distance/_distance.pyx":103 + /* "Orange/distance/_distance.pyx":104 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -3471,23 +3479,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_v_n_rows = __pyx_t_4; __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":104 + /* "Orange/distance/_distance.pyx":105 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -3495,27 +3503,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 104, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 104, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":105 + /* "Orange/distance/_distance.pyx":106 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -3529,7 +3537,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":106 + /* "Orange/distance/_distance.pyx":107 * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -3540,7 +3548,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":107 + /* "Orange/distance/_distance.pyx":108 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -3551,7 +3559,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":108 + /* "Orange/distance/_distance.pyx":109 * for col1 in range(n_cols): * for col2 in range(col1): * d = 0 # <<<<<<<<<<<<<< @@ -3560,7 +3568,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":109 + /* "Orange/distance/_distance.pyx":110 * for col2 in range(col1): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -3571,7 +3579,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":110 + /* "Orange/distance/_distance.pyx":111 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -3587,7 +3595,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":111 + /* "Orange/distance/_distance.pyx":112 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -3597,7 +3605,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (__pyx_v_normalize != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":112 + /* "Orange/distance/_distance.pyx":113 * val1, val2 = x[row, col1], x[row, col2] * if normalize: * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) # <<<<<<<<<<<<<< @@ -3608,7 +3616,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_24 = __pyx_v_col1; __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_23 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_24 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":113 + /* "Orange/distance/_distance.pyx":114 * if normalize: * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) # <<<<<<<<<<<<<< @@ -3619,7 +3627,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_26 = __pyx_v_col2; __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_25 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_26 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":114 + /* "Orange/distance/_distance.pyx":115 * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3629,7 +3637,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":116 * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3639,7 +3647,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":117 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -3648,7 +3656,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":116 * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3658,7 +3666,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":118 + /* "Orange/distance/_distance.pyx":119 * d += 1 * else: * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3670,7 +3678,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L14:; - /* "Orange/distance/_distance.pyx":114 + /* "Orange/distance/_distance.pyx":115 * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3680,7 +3688,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":120 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3690,7 +3698,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":120 + /* "Orange/distance/_distance.pyx":121 * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3699,7 +3707,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":120 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3709,7 +3717,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":122 + /* "Orange/distance/_distance.pyx":123 * d += val1 ** 2 + 0.5 * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3721,7 +3729,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":111 + /* "Orange/distance/_distance.pyx":112 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -3731,7 +3739,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":124 + /* "Orange/distance/_distance.pyx":125 * d += (val1 - val2) ** 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3742,7 +3750,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":126 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3752,7 +3760,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":126 + /* "Orange/distance/_distance.pyx":127 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -3762,7 +3770,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_27 = __pyx_v_col1; __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":127 + /* "Orange/distance/_distance.pyx":128 * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< @@ -3772,7 +3780,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":126 + /* "Orange/distance/_distance.pyx":127 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -3781,7 +3789,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_27 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_28 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_29 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":126 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3791,7 +3799,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":129 + /* "Orange/distance/_distance.pyx":130 * + (means[col1] - means[col2]) ** 2 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< @@ -3805,7 +3813,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L16:; - /* "Orange/distance/_distance.pyx":124 + /* "Orange/distance/_distance.pyx":125 * d += (val1 - val2) ** 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3815,7 +3823,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":130 + /* "Orange/distance/_distance.pyx":131 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3825,7 +3833,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":131 + /* "Orange/distance/_distance.pyx":132 * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< @@ -3836,7 +3844,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_34 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":130 + /* "Orange/distance/_distance.pyx":131 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3846,7 +3854,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":133 + /* "Orange/distance/_distance.pyx":134 * d += (val1 - means[col2]) ** 2 + vars[col2] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3861,7 +3869,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_L12:; } - /* "Orange/distance/_distance.pyx":134 + /* "Orange/distance/_distance.pyx":135 * else: * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -3878,7 +3886,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":105 + /* "Orange/distance/_distance.pyx":106 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -3896,7 +3904,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":135 + /* "Orange/distance/_distance.pyx":136 * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d * return np.sqrt(distances) # <<<<<<<<<<<<<< @@ -3904,12 +3912,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { @@ -3922,17 +3930,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_39); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_39, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_39, 0+1, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0; } @@ -3941,7 +3949,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":93 + /* "Orange/distance/_distance.pyx":94 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -3978,32 +3986,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":138 +/* "Orange/distance/_distance.pyx":139 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ /* Python wrapper */ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, fit_params)"; +static char __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows = {"manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows}; static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("manhattan_rows (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; - PyObject* values[3] = {0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -4018,39 +4028,46 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, 1); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 139, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 139, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, 2); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 139, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 138, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 139, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_fit_params = values[2]; + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 139, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 138, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 139, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 139, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ goto __pyx_L0; @@ -4061,13 +4078,12 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; char __pyx_v_normalize; - char __pyx_v_same; int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -4090,9 +4106,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; char __pyx_t_4; - int __pyx_t_5; + npy_intp __pyx_t_5; npy_intp __pyx_t_6; - npy_intp __pyx_t_7; + int __pyx_t_7; Py_ssize_t __pyx_t_8; Py_ssize_t __pyx_t_9; Py_ssize_t __pyx_t_10; @@ -4142,115 +4158,105 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 139, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 139, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":142 + /* "Orange/distance/_distance.pyx":144 * fit_params): * cdef: * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 142, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_medians = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":143 + /* "Orange/distance/_distance.pyx":145 * cdef: * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 143, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mads = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":144 + /* "Orange/distance/_distance.pyx":146 * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 144, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":145 + /* "Orange/distance/_distance.pyx":147 * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] - * char same = x1 is x2 + * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 145, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":146 + /* "Orange/distance/_distance.pyx":148 * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * char same = x1 is x2 * + * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_4; - /* "Orange/distance/_distance.pyx":147 - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] - * char same = x1 is x2 # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_5 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); - __pyx_v_same = __pyx_t_5; - - /* "Orange/distance/_distance.pyx":154 + /* "Orange/distance/_distance.pyx":155 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ */ - __pyx_t_6 = (__pyx_v_x1->dimensions[0]); - __pyx_t_7 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_6; - __pyx_v_n_cols = __pyx_t_7; + __pyx_t_5 = (__pyx_v_x1->dimensions[0]); + __pyx_t_6 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_5; + __pyx_v_n_cols = __pyx_t_6; - /* "Orange/distance/_distance.pyx":155 + /* "Orange/distance/_distance.pyx":156 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -4259,7 +4265,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":156 + /* "Orange/distance/_distance.pyx":157 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< @@ -4268,75 +4274,75 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_8 == __pyx_t_9); - if (__pyx_t_5) { + __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":157 + /* "Orange/distance/_distance.pyx":158 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< * * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_9 == __pyx_t_10); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_10 == __pyx_t_11); + __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); } } } } - /* "Orange/distance/_distance.pyx":156 + /* "Orange/distance/_distance.pyx":157 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< * == len(dist_missing) == len(dist_missing2) * */ - if (unlikely(!(__pyx_t_5 != 0))) { + if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 156, __pyx_L1_error) + __PYX_ERR(0, 157, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":159 + /* "Orange/distance/_distance.pyx":160 * == len(dist_missing) == len(dist_missing2) * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); @@ -4344,63 +4350,63 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); __pyx_t_1 = 0; __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 159, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 159, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":160 + /* "Orange/distance/_distance.pyx":161 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 */ __pyx_t_15 = __pyx_v_n_rows1; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":161 + /* "Orange/distance/_distance.pyx":162 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< * d = 0 * for col in range(n_cols): */ - if ((__pyx_v_same != 0)) { - __pyx_t_17 = __pyx_v_row1; - } else { + if ((__pyx_v_two_tables != 0)) { __pyx_t_17 = __pyx_v_n_rows2; + } else { + __pyx_t_17 = __pyx_v_row1; } for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_row2 = __pyx_t_18; - /* "Orange/distance/_distance.pyx":162 + /* "Orange/distance/_distance.pyx":163 * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): * if mads[col] == -2: */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":163 - * for row2 in range(row1 if same else n_rows2): + /* "Orange/distance/_distance.pyx":164 + * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< * if mads[col] == -2: @@ -4410,7 +4416,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":164 + /* "Orange/distance/_distance.pyx":165 * d = 0 * for col in range(n_cols): * if mads[col] == -2: # <<<<<<<<<<<<<< @@ -4418,10 +4424,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * */ __pyx_t_21 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":165 + /* "Orange/distance/_distance.pyx":166 * for col in range(n_cols): * if mads[col] == -2: * continue # <<<<<<<<<<<<<< @@ -4430,7 +4436,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ goto __pyx_L7_continue; - /* "Orange/distance/_distance.pyx":164 + /* "Orange/distance/_distance.pyx":165 * d = 0 * for col in range(n_cols): * if mads[col] == -2: # <<<<<<<<<<<<<< @@ -4439,7 +4445,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ } - /* "Orange/distance/_distance.pyx":167 + /* "Orange/distance/_distance.pyx":168 * continue * * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -4455,7 +4461,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_v_val1 = __pyx_t_24; __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":169 * * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4465,15 +4471,15 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_28) { } else { - __pyx_t_5 = __pyx_t_28; + __pyx_t_7 = __pyx_t_28; goto __pyx_L11_bool_binop_done; } __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_5 = __pyx_t_28; + __pyx_t_7 = __pyx_t_28; __pyx_L11_bool_binop_done:; - if (__pyx_t_5) { + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":169 + /* "Orange/distance/_distance.pyx":170 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -4483,7 +4489,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_29 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":169 * * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4493,7 +4499,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":170 + /* "Orange/distance/_distance.pyx":171 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif mads[col] == -1: # <<<<<<<<<<<<<< @@ -4501,10 +4507,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * if npy_isnan(val1): */ __pyx_t_30 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":171 + /* "Orange/distance/_distance.pyx":172 * d += dist_missing2[col] * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< @@ -4514,17 +4520,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_v_ival1 = ((int)__pyx_v_val1); __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":172 + /* "Orange/distance/_distance.pyx":173 * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< * d += dist_missing[col, ival2] * elif npy_isnan(val2): */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":173 + /* "Orange/distance/_distance.pyx":174 * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< @@ -4535,7 +4541,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_32 = __pyx_v_ival2; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":172 + /* "Orange/distance/_distance.pyx":173 * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4545,17 +4551,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":174 + /* "Orange/distance/_distance.pyx":175 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += dist_missing[col, ival1] * elif ival1 != ival2: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":175 + /* "Orange/distance/_distance.pyx":176 * d += dist_missing[col, ival2] * elif npy_isnan(val2): * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< @@ -4566,7 +4572,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_34 = __pyx_v_ival1; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":174 + /* "Orange/distance/_distance.pyx":175 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4576,17 +4582,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":176 + /* "Orange/distance/_distance.pyx":177 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< * d += 1 * elif normalize: */ - __pyx_t_5 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":177 + /* "Orange/distance/_distance.pyx":178 * d += dist_missing[col, ival1] * elif ival1 != ival2: * d += 1 # <<<<<<<<<<<<<< @@ -4595,7 +4601,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":176 + /* "Orange/distance/_distance.pyx":177 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -4605,7 +4611,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":170 + /* "Orange/distance/_distance.pyx":171 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif mads[col] == -1: # <<<<<<<<<<<<<< @@ -4615,27 +4621,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":178 + /* "Orange/distance/_distance.pyx":179 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_5 = (__pyx_v_normalize != 0); - if (__pyx_t_5) { + __pyx_t_7 = (__pyx_v_normalize != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":179 + /* "Orange/distance/_distance.pyx":180 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":180 + /* "Orange/distance/_distance.pyx":181 * elif normalize: * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -4646,7 +4652,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_36 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":179 + /* "Orange/distance/_distance.pyx":180 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4656,17 +4662,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":181 + /* "Orange/distance/_distance.pyx":182 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":182 + /* "Orange/distance/_distance.pyx":183 * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -4677,7 +4683,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_38 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":181 + /* "Orange/distance/_distance.pyx":182 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4687,7 +4693,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":184 + /* "Orange/distance/_distance.pyx":185 * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 * else: * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< @@ -4700,7 +4706,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } __pyx_L14:; - /* "Orange/distance/_distance.pyx":178 + /* "Orange/distance/_distance.pyx":179 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -4710,7 +4716,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":186 + /* "Orange/distance/_distance.pyx":187 * d += fabs(val1 - val2) / mads[col] / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4718,10 +4724,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * elif npy_isnan(val2): */ /*else*/ { - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":187 + /* "Orange/distance/_distance.pyx":188 * else: * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -4732,7 +4738,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_41 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":186 + /* "Orange/distance/_distance.pyx":187 * d += fabs(val1 - val2) / mads[col] / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4742,17 +4748,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":189 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< * d += fabs(val1 - medians[col]) + mads[col] * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":189 + /* "Orange/distance/_distance.pyx":190 * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -4763,7 +4769,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_43 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":189 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4773,7 +4779,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":191 + /* "Orange/distance/_distance.pyx":192 * d += fabs(val1 - medians[col]) + mads[col] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -4789,12 +4795,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_L7_continue:; } - /* "Orange/distance/_distance.pyx":193 + /* "Orange/distance/_distance.pyx":194 * d += fabs(val1 - val2) * * distances[row1, row2] = d # <<<<<<<<<<<<<< * - * if same: + * if not two_tables: */ __pyx_t_44 = __pyx_v_row1; __pyx_t_45 = __pyx_v_row2; @@ -4802,56 +4808,54 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":195 + /* "Orange/distance/_distance.pyx":196 * distances[row1, row2] = d * - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ - __pyx_t_5 = (__pyx_v_same != 0); - if (__pyx_t_5) { + __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":196 + /* "Orange/distance/_distance.pyx":197 * - * if same: + * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances * */ - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":195 + /* "Orange/distance/_distance.pyx":196 * distances[row1, row2] = d * - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":197 - * if same: + /* "Orange/distance/_distance.pyx":198 + * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":138 + /* "Orange/distance/_distance.pyx":139 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ /* function exit code */ @@ -4886,7 +4890,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":200 +/* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -4924,11 +4928,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 200, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 201, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 200, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 201, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4941,13 +4945,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 200, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 201, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -5021,56 +5025,56 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 200, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 201, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":202 + /* "Orange/distance/_distance.pyx":203 * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 202, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_medians = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":203 + /* "Orange/distance/_distance.pyx":204 * cdef: * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mads = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":204 + /* "Orange/distance/_distance.pyx":205 * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_3; - /* "Orange/distance/_distance.pyx":210 + /* "Orange/distance/_distance.pyx":211 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -5082,23 +5086,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_v_n_rows = __pyx_t_4; __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":212 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -5106,27 +5110,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 211, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":212 + /* "Orange/distance/_distance.pyx":213 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -5137,7 +5141,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":214 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -5148,7 +5152,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":214 + /* "Orange/distance/_distance.pyx":215 * for col1 in range(n_cols): * for col2 in range(col1): * d = 0 # <<<<<<<<<<<<<< @@ -5157,7 +5161,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":215 + /* "Orange/distance/_distance.pyx":216 * for col2 in range(col1): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -5168,7 +5172,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":216 + /* "Orange/distance/_distance.pyx":217 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -5184,7 +5188,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":217 + /* "Orange/distance/_distance.pyx":218 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -5194,7 +5198,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (__pyx_v_normalize != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":218 + /* "Orange/distance/_distance.pyx":219 * val1, val2 = x[row, col1], x[row, col2] * if normalize: * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< @@ -5205,7 +5209,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_24 = __pyx_v_col1; __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":219 + /* "Orange/distance/_distance.pyx":220 * if normalize: * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< @@ -5216,7 +5220,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_26 = __pyx_v_col2; __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":220 + /* "Orange/distance/_distance.pyx":221 * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5226,7 +5230,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":221 + /* "Orange/distance/_distance.pyx":222 * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5236,7 +5240,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":222 + /* "Orange/distance/_distance.pyx":223 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -5245,7 +5249,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":221 + /* "Orange/distance/_distance.pyx":222 * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5255,7 +5259,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":224 + /* "Orange/distance/_distance.pyx":225 * d += 1 * else: * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< @@ -5267,7 +5271,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L11:; - /* "Orange/distance/_distance.pyx":220 + /* "Orange/distance/_distance.pyx":221 * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5277,7 +5281,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":225 + /* "Orange/distance/_distance.pyx":226 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5287,7 +5291,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":226 + /* "Orange/distance/_distance.pyx":227 * d += fabs(val2) + 0.5 * elif npy_isnan(val2): * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< @@ -5296,7 +5300,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":225 + /* "Orange/distance/_distance.pyx":226 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5306,7 +5310,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":228 + /* "Orange/distance/_distance.pyx":229 * d += fabs(val1) + 0.5 * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -5318,7 +5322,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L10:; - /* "Orange/distance/_distance.pyx":217 + /* "Orange/distance/_distance.pyx":218 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -5328,7 +5332,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":230 + /* "Orange/distance/_distance.pyx":231 * d += fabs(val1 - val2) * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5339,7 +5343,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":232 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5349,7 +5353,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":233 * if npy_isnan(val1): * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -5359,7 +5363,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_27 = __pyx_v_col1; __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":233 + /* "Orange/distance/_distance.pyx":234 * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< @@ -5369,7 +5373,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":233 * if npy_isnan(val1): * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -5378,7 +5382,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":232 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5388,7 +5392,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":235 + /* "Orange/distance/_distance.pyx":236 * + fabs(medians[col1] - medians[col2]) * else: * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< @@ -5402,7 +5406,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":230 + /* "Orange/distance/_distance.pyx":231 * d += fabs(val1 - val2) * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5412,7 +5416,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":237 * else: * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5422,7 +5426,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":237 + /* "Orange/distance/_distance.pyx":238 * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< @@ -5433,7 +5437,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":237 * else: * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5443,7 +5447,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":239 + /* "Orange/distance/_distance.pyx":240 * d += fabs(val1 - medians[col2]) + mads[col2] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -5458,7 +5462,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_L9:; } - /* "Orange/distance/_distance.pyx":240 + /* "Orange/distance/_distance.pyx":241 * else: * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -5474,7 +5478,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":241 + /* "Orange/distance/_distance.pyx":242 * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< @@ -5482,13 +5486,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -5524,525 +5528,2599 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":244 +/* "Orange/distance/_distance.pyx":245 * * - * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: - * int row, n_cols, nonzeros, nonnans + * int row, nonzeros, nonnans */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_8fit_jaccard[] = "fit_jaccard(ndarray x, *_)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9fit_jaccard = {"fit_jaccard", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_8fit_jaccard}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fit_jaccard(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - CYTHON_UNUSED PyObject *__pyx_v__ = 0; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_8p_nonzero[] = "p_nonzero(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_8p_nonzero}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("fit_jaccard (wrapper)", 0); - if (PyTuple_GET_SIZE(__pyx_args) > 1) { - __pyx_v__ = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); - if (unlikely(!__pyx_v__)) { - __Pyx_RefNannyFinishContext(); - return NULL; - } - __Pyx_GOTREF(__pyx_v__); - } else { - __pyx_v__ = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); - } - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - default: - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "fit_jaccard") < 0)) __PYX_ERR(0, 244, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fit_jaccard", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 244, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_DECREF(__pyx_v__); __pyx_v__ = 0; - __Pyx_AddTraceback("Orange.distance._distance.fit_jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 244, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(__pyx_self, __pyx_v_x, __pyx_v__); + __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v__); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fit_jaccard(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, CYTHON_UNUSED PyObject *__pyx_v__) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { int __pyx_v_row; - int __pyx_v_n_cols; int __pyx_v_nonzeros; int __pyx_v_nonnans; double __pyx_v_val; - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_v_col; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; PyObject *__pyx_t_5 = NULL; - __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_7; - int __pyx_t_8; - Py_ssize_t __pyx_t_9; - int __pyx_t_10; - Py_ssize_t __pyx_t_11; - Py_ssize_t __pyx_t_12; - int __pyx_t_13; - Py_ssize_t __pyx_t_14; - __Pyx_RefNannySetupContext("fit_jaccard", 0); + __Pyx_RefNannySetupContext("p_nonzero", 0); __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 244, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 245, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; /* "Orange/distance/_distance.pyx":250 - * double [:] ps + * double val * - * n_cols = x.shape[1] # <<<<<<<<<<<<<< - * ps = np.empty(n_cols, dtype=np.double) - * for col in range(n_cols): + * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< + * for row in range(len(x)): + * val = x[row] */ - __pyx_v_n_cols = (__pyx_v_x->dimensions[1]); + __pyx_v_nonzeros = 0; + __pyx_v_nonnans = 0; /* "Orange/distance/_distance.pyx":251 * - * n_cols = x.shape[1] - * ps = np.empty(n_cols, dtype=np.double) # <<<<<<<<<<<<<< - * for col in range(n_cols): - * nonzeros = nonnans = 0 + * nonzeros = nonnans = 0 + * for row in range(len(x)): # <<<<<<<<<<<<<< + * val = x[row] + * if not npy_isnan(val): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_double); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5); - if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_ps = __pyx_t_6; - __pyx_t_6.memview = NULL; - __pyx_t_6.data = NULL; + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 251, __pyx_L1_error) + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":252 - * n_cols = x.shape[1] - * ps = np.empty(n_cols, dtype=np.double) - * for col in range(n_cols): # <<<<<<<<<<<<<< - * nonzeros = nonnans = 0 - * for row in range(len(x)): + /* "Orange/distance/_distance.pyx":252 + * nonzeros = nonnans = 0 + * for row in range(len(x)): + * val = x[row] # <<<<<<<<<<<<<< + * if not npy_isnan(val): + * nonnans += 1 */ - __pyx_t_7 = __pyx_v_n_cols; - for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { - __pyx_v_col = __pyx_t_8; + __pyx_t_3 = __pyx_v_row; + __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); /* "Orange/distance/_distance.pyx":253 - * ps = np.empty(n_cols, dtype=np.double) - * for col in range(n_cols): - * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< - * for row in range(len(x)): - * val = x[row, col] - */ - __pyx_v_nonzeros = 0; - __pyx_v_nonnans = 0; - - /* "Orange/distance/_distance.pyx":254 - * for col in range(n_cols): - * nonzeros = nonnans = 0 - * for row in range(len(x)): # <<<<<<<<<<<<<< - * val = x[row, col] - * if not npy_isnan(val): - */ - __pyx_t_9 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 254, __pyx_L1_error) - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_row = __pyx_t_10; + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: + */ + __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); + if (__pyx_t_4) { + + /* "Orange/distance/_distance.pyx":254 + * val = x[row] + * if not npy_isnan(val): + * nonnans += 1 # <<<<<<<<<<<<<< + * if val != 0: + * nonzeros += 1 + */ + __pyx_v_nonnans = (__pyx_v_nonnans + 1); /* "Orange/distance/_distance.pyx":255 - * nonzeros = nonnans = 0 - * for row in range(len(x)): - * val = x[row, col] # <<<<<<<<<<<<<< - * if not npy_isnan(val): - * nonnans += 1 - */ - __pyx_t_11 = __pyx_v_row; - __pyx_t_12 = __pyx_v_col; - __pyx_v_val = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_x.diminfo[1].strides)); - - /* "Orange/distance/_distance.pyx":256 - * for row in range(len(x)): - * val = x[row, col] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: - */ - __pyx_t_13 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); - if (__pyx_t_13) { - - /* "Orange/distance/_distance.pyx":257 - * val = x[row, col] - * if not npy_isnan(val): - * nonnans += 1 # <<<<<<<<<<<<<< - * if val != 0: - * nonzeros += 1 - */ - __pyx_v_nonnans = (__pyx_v_nonnans + 1); - - /* "Orange/distance/_distance.pyx":258 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * ps[col] = float(nonzeros) / nonnans - */ - __pyx_t_13 = ((__pyx_v_val != 0.0) != 0); - if (__pyx_t_13) { - - /* "Orange/distance/_distance.pyx":259 - * nonnans += 1 - * if val != 0: - * nonzeros += 1 # <<<<<<<<<<<<<< - * ps[col] = float(nonzeros) / nonnans - * return {"ps": ps} - */ - __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - - /* "Orange/distance/_distance.pyx":258 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * ps[col] = float(nonzeros) / nonnans + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ - } + __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_4) { /* "Orange/distance/_distance.pyx":256 - * for row in range(len(x)): - * val = x[row, col] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: + * nonnans += 1 + * if val != 0: + * nonzeros += 1 # <<<<<<<<<<<<<< + * return float(nonzeros) / nonnans + * + */ + __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); + + /* "Orange/distance/_distance.pyx":255 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ } - } - /* "Orange/distance/_distance.pyx":260 - * if val != 0: - * nonzeros += 1 - * ps[col] = float(nonzeros) / nonnans # <<<<<<<<<<<<<< - * return {"ps": ps} - * + /* "Orange/distance/_distance.pyx":253 + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: */ - __pyx_t_14 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_14 * __pyx_v_ps.strides[0]) )) = (((double)__pyx_v_nonzeros) / __pyx_v_nonnans); + } } - /* "Orange/distance/_distance.pyx":261 - * nonzeros += 1 - * ps[col] = float(nonzeros) / nonnans - * return {"ps": ps} # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":257 + * if val != 0: + * nonzeros += 1 + * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_ps, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_ps, __pyx_t_1) < 0) __PYX_ERR(0, 261, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":245 * * - * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: - * int row, n_cols, nonzeros, nonnans + * int row, nonzeros, nonnans */ /* 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_XDECREF(__pyx_t_5); - __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.fit_jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.p_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":264 +/* "Orange/distance/_distance.pyx":260 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss */ -/* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_10jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10jaccard_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x1 = 0; - PyArrayObject *__pyx_v_x2 = 0; - PyObject *__pyx_v_fit_params = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_fit_params,0}; - PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, 1); __PYX_ERR(0, 264, __pyx_L3_error) - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, 2); __PYX_ERR(0, 264, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 264, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - 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); - } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_fit_params = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 264, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 264, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 265, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_fit_params); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_same; - int __pyx_v_n_rows1; - int __pyx_v_n_rows2; - int __pyx_v_n_cols; - int __pyx_v_row1; - int __pyx_v_row2; +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + double __pyx_v_d; + double __pyx_v_val; + int __pyx_v_row; int __pyx_v_col; - double __pyx_v_val1; - double __pyx_v_val2; - double __pyx_v_intersection; - double __pyx_v_union; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; - __Pyx_Buffer __pyx_pybuffer_x1; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; - __Pyx_Buffer __pyx_pybuffer_x2; + int __pyx_v_n_rows; + int __pyx_v_n_cols; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_3; - npy_intp __pyx_t_4; - npy_intp __pyx_t_5; + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; int __pyx_t_12; - int __pyx_t_13; + Py_ssize_t __pyx_t_13; int __pyx_t_14; - int __pyx_t_15; + Py_ssize_t __pyx_t_15; Py_ssize_t __pyx_t_16; Py_ssize_t __pyx_t_17; - __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; Py_ssize_t __pyx_t_20; - __pyx_t_5numpy_float64_t __pyx_t_21; - Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - int __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - __Pyx_RefNannySetupContext("jaccard_rows", 0); - __pyx_pybuffer_x1.pybuffer.buf = NULL; - __pyx_pybuffer_x1.refcount = 0; - __pyx_pybuffernd_x1.data = NULL; - __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; - __pyx_pybuffer_x2.pybuffer.buf = NULL; + Py_ssize_t __pyx_t_21; + __Pyx_RefNannySetupContext("_abs_rows", 0); + + /* "Orange/distance/_distance.pyx":266 + * int row, col, n_rows, n_cols + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * abss = np.empty(n_rows) + * with nogil: + */ + __pyx_t_1 = (__pyx_v_x.shape[0]); + __pyx_t_2 = (__pyx_v_x.shape[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; + + /* "Orange/distance/_distance.pyx":267 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) # <<<<<<<<<<<<<< + * with nogil: + * for row in range(n_rows): + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_6) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_abss = __pyx_t_8; + __pyx_t_8.memview = NULL; + __pyx_t_8.data = NULL; + + /* "Orange/distance/_distance.pyx":268 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * d = 0 + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":269 + * abss = np.empty(n_rows) + * with nogil: + * for row in range(n_rows): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + __pyx_t_9 = __pyx_v_n_rows; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_row = __pyx_t_10; + + /* "Orange/distance/_distance.pyx":270 + * with nogil: + * for row in range(n_rows): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":271 + * for row in range(n_rows): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: + * continue + */ + __pyx_t_11 = __pyx_v_n_cols; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_col = __pyx_t_12; + + /* "Orange/distance/_distance.pyx":272 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val = x[row, col] + */ + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_14) { + + /* "Orange/distance/_distance.pyx":273 + * for col in range(n_cols): + * if vars[col] == -2: + * continue # <<<<<<<<<<<<<< + * val = x[row, col] + * if vars[col] == -1: + */ + goto __pyx_L8_continue; + + /* "Orange/distance/_distance.pyx":272 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val = x[row, col] + */ + } + + /* "Orange/distance/_distance.pyx":274 + * if vars[col] == -2: + * continue + * val = x[row, col] # <<<<<<<<<<<<<< + * if vars[col] == -1: + * if npy_isnan(val): + */ + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col; + __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); + + /* "Orange/distance/_distance.pyx":275 + * continue + * val = x[row, col] + * if vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val): + * d += means[col] + */ + __pyx_t_17 = __pyx_v_col; + __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_14) { + + /* "Orange/distance/_distance.pyx":276 + * val = x[row, col] + * if vars[col] == -1: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] + * elif val != 0: + */ + __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_14) { + + /* "Orange/distance/_distance.pyx":277 + * if vars[col] == -1: + * if npy_isnan(val): + * d += means[col] # <<<<<<<<<<<<<< + * elif val != 0: + * d += 1 + */ + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":276 + * val = x[row, col] + * if vars[col] == -1: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] + * elif val != 0: + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":278 + * if npy_isnan(val): + * d += means[col] + * elif val != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_14) { + + /* "Orange/distance/_distance.pyx":279 + * d += means[col] + * elif val != 0: + * d += 1 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val): + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":278 + * if npy_isnan(val): + * d += means[col] + * elif val != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + } + __pyx_L12:; + + /* "Orange/distance/_distance.pyx":275 + * continue + * val = x[row, col] + * if vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val): + * d += means[col] + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":281 + * d += 1 + * else: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] ** 2 + vars[col] + * else: + */ + /*else*/ { + __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_14) { + + /* "Orange/distance/_distance.pyx":282 + * else: + * if npy_isnan(val): + * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< + * else: + * d += val ** 2 + */ + __pyx_t_19 = __pyx_v_col; + __pyx_t_20 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":281 + * d += 1 + * else: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] ** 2 + vars[col] + * else: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":284 + * d += means[col] ** 2 + vars[col] + * else: + * d += val ** 2 # <<<<<<<<<<<<<< + * abss[row] = sqrt(d) + * return abss + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); + } + __pyx_L13:; + } + __pyx_L11:; + __pyx_L8_continue:; + } + + /* "Orange/distance/_distance.pyx":285 + * else: + * d += val ** 2 + * abss[row] = sqrt(d) # <<<<<<<<<<<<<< + * return abss + * + */ + __pyx_t_21 = __pyx_v_row; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_21 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); + } + } + + /* "Orange/distance/_distance.pyx":268 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * d = 0 + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":286 + * d += val ** 2 + * abss[row] = sqrt(d) + * return abss # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":260 + * + * + * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_AddTraceback("Orange.distance._distance._abs_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":289 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_10cosine_rows[] = "cosine_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11cosine_rows = {"cosine_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11cosine_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10cosine_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("cosine_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 289, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 289, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 289, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 289, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L3_error) + __pyx_v_fit_params = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 289, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 289, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_abs1 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_abs2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + Py_ssize_t __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + __pyx_t_5numpy_float64_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + __pyx_t_5numpy_float64_t __pyx_t_26; + int __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + __Pyx_RefNannySetupContext("cosine_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 289, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 289, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":294 + * fit_params): + * cdef: + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * double [:] means = fit_params["means"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 294, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":295 + * cdef: + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< + * double [:] dist_missing2 = fit_params["dist_missing2"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":296 + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] + * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":303 + * double [:, :] distances + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + */ + __pyx_t_3 = (__pyx_v_x1->dimensions[0]); + __pyx_t_4 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":304 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) + */ + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); + + /* "Orange/distance/_distance.pyx":305 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":306 + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) # <<<<<<<<<<<<<< + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + */ + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); + } + } + } + + /* "Orange/distance/_distance.pyx":305 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) + */ + if (unlikely(!(__pyx_t_5 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 305, __pyx_L1_error) + } + } + #endif + + /* "Orange/distance/_distance.pyx":307 + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + */ + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_abs1 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":308 + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + */ + if ((__pyx_v_two_tables != 0)) { + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = __pyx_t_10; + __pyx_t_10.memview = NULL; + __pyx_t_10.data = NULL; + } else { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = __pyx_t_10; + __pyx_t_10.memview = NULL; + __pyx_t_10.data = NULL; + } + __pyx_v_abs2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":309 + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * + * with nogil: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); + __pyx_t_1 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; + + /* "Orange/distance/_distance.pyx":311 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":312 + * + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 + */ + __pyx_t_14 = __pyx_v_n_rows1; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row1 = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":313 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_two_tables != 0)) { + __pyx_t_16 = __pyx_v_n_rows2; + } else { + __pyx_t_16 = __pyx_v_row1; + } + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_row2 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":314 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":315 + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: + * continue + */ + __pyx_t_18 = __pyx_v_n_cols; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_col = __pyx_t_19; + + /* "Orange/distance/_distance.pyx":316 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + */ + __pyx_t_20 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":317 + * for col in range(n_cols): + * if vars[col] == -2: + * continue # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + */ + goto __pyx_L10_continue; + + /* "Orange/distance/_distance.pyx":316 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + */ + } + + /* "Orange/distance/_distance.pyx":318 + * if vars[col] == -2: + * continue + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + */ + __pyx_t_21 = __pyx_v_row1; + __pyx_t_22 = __pyx_v_col; + __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_24 = __pyx_v_row2; + __pyx_t_25 = __pyx_v_col; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_23; + __pyx_v_val2 = __pyx_t_26; + + /* "Orange/distance/_distance.pyx":319 + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: + */ + __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L14_bool_binop_done:; + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":320 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ + */ + __pyx_t_28 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":319 + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":321 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: + */ + __pyx_t_29 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":322 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + */ + __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); + if (!__pyx_t_27) { + goto __pyx_L18_next_or; + } else { + } + __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); + if (!__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L17_bool_binop_done; + } + __pyx_L18_next_or:; + + /* "Orange/distance/_distance.pyx":323 + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< + * d += means[col] + * elif val1 != 0 and val2 != 0: + */ + __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L17_bool_binop_done; + } + __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L17_bool_binop_done:; + + /* "Orange/distance/_distance.pyx":322 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + */ + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":324 + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: + * d += means[col] # <<<<<<<<<<<<<< + * elif val1 != 0 and val2 != 0: + * d += 1 + */ + __pyx_t_30 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); + + /* "Orange/distance/_distance.pyx":322 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":325 + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L21_bool_binop_done; + } + __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L21_bool_binop_done:; + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":326 + * d += means[col] + * elif val1 != 0 and val2 != 0: + * d += 1 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":325 + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + } + __pyx_L16:; + + /* "Orange/distance/_distance.pyx":321 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":328 + * d += 1 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col] + * elif npy_isnan(val2): + */ + /*else*/ { + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":329 + * else: + * if npy_isnan(val1): + * d += val2 * means[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 * means[col] + */ + __pyx_t_31 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":328 + * d += 1 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col] + * elif npy_isnan(val2): + */ + goto __pyx_L23; + } + + /* "Orange/distance/_distance.pyx":330 + * if npy_isnan(val1): + * d += val2 * means[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col] + * else: + */ + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":331 + * d += val2 * means[col] + * elif npy_isnan(val2): + * d += val1 * means[col] # <<<<<<<<<<<<<< + * else: + * d += val1 * val2 + */ + __pyx_t_32 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":330 + * if npy_isnan(val1): + * d += val2 * means[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col] + * else: + */ + goto __pyx_L23; + } + + /* "Orange/distance/_distance.pyx":333 + * d += val1 * means[col] + * else: + * d += val1 * val2 # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * if not two_tables: + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); + } + __pyx_L23:; + } + __pyx_L13:; + __pyx_L10_continue:; + } + + /* "Orange/distance/_distance.pyx":334 + * else: + * d += val1 * val2 + * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) # <<<<<<<<<<<<<< + * if not two_tables: + * _lower_to_symmetric(distances) + */ + __pyx_t_33 = __pyx_v_row1; + __pyx_t_34 = __pyx_v_row2; + __pyx_t_35 = __pyx_v_row1; + __pyx_t_36 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = (1.0 - cos(((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) )))))); + } + } + } + + /* "Orange/distance/_distance.pyx":311 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":335 + * d += val1 * val2 + * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":336 + * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); + + /* "Orange/distance/_distance.pyx":335 + * d += val1 * val2 + * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + } + + /* "Orange/distance/_distance.pyx":337 + * if not two_tables: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":289 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abs1, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abs2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":340 + * + * + * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss + */ + +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + double __pyx_v_d; + double __pyx_v_val; + int __pyx_v_row; + int __pyx_v_col; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_nan_cont; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_9; + int __pyx_t_10; + Py_ssize_t __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + __Pyx_RefNannySetupContext("_abs_cols", 0); + + /* "Orange/distance/_distance.pyx":346 + * int row, col, n_rows, n_cols, nan_cont + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * abss = np.empty(n_cols) + * with nogil: + */ + __pyx_t_1 = (__pyx_v_x.shape[0]); + __pyx_t_2 = (__pyx_v_x.shape[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; + + /* "Orange/distance/_distance.pyx":347 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_cols) # <<<<<<<<<<<<<< + * with nogil: + * for col in range(n_cols): + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_6) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 347, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_abss = __pyx_t_8; + __pyx_t_8.memview = NULL; + __pyx_t_8.data = NULL; + + /* "Orange/distance/_distance.pyx":348 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_cols) + * with nogil: # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":349 + * abss = np.empty(n_cols) + * with nogil: + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: + * continue + */ + __pyx_t_9 = __pyx_v_n_cols; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_col = __pyx_t_10; + + /* "Orange/distance/_distance.pyx":350 + * with nogil: + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 + */ + __pyx_t_11 = __pyx_v_col; + __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_12) { + + /* "Orange/distance/_distance.pyx":351 + * for col in range(n_cols): + * if vars[col] == -2: + * continue # <<<<<<<<<<<<<< + * d = 0 + * nan_cont = 0 + */ + goto __pyx_L6_continue; + + /* "Orange/distance/_distance.pyx":350 + * with nogil: + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 + */ + } + + /* "Orange/distance/_distance.pyx":352 + * if vars[col] == -2: + * continue + * d = 0 # <<<<<<<<<<<<<< + * nan_cont = 0 + * for row in range(n_rows): + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":353 + * continue + * d = 0 + * nan_cont = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val = x[row, col] + */ + __pyx_v_nan_cont = 0; + + /* "Orange/distance/_distance.pyx":354 + * d = 0 + * nan_cont = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val = x[row, col] + * if npy_isnan(val): + */ + __pyx_t_13 = __pyx_v_n_rows; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_v_row = __pyx_t_14; + + /* "Orange/distance/_distance.pyx":355 + * nan_cont = 0 + * for row in range(n_rows): + * val = x[row, col] # <<<<<<<<<<<<<< + * if npy_isnan(val): + * nan_cont += 1 + */ + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col; + __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); + + /* "Orange/distance/_distance.pyx":356 + * for row in range(n_rows): + * val = x[row, col] + * if npy_isnan(val): # <<<<<<<<<<<<<< + * nan_cont += 1 + * else: + */ + __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_12) { + + /* "Orange/distance/_distance.pyx":357 + * val = x[row, col] + * if npy_isnan(val): + * nan_cont += 1 # <<<<<<<<<<<<<< + * else: + * d += val ** 2 + */ + __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); + + /* "Orange/distance/_distance.pyx":356 + * for row in range(n_rows): + * val = x[row, col] + * if npy_isnan(val): # <<<<<<<<<<<<<< + * nan_cont += 1 + * else: + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":359 + * nan_cont += 1 + * else: + * d += val ** 2 # <<<<<<<<<<<<<< + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); + } + __pyx_L11:; + } + + /* "Orange/distance/_distance.pyx":360 + * else: + * d += val ** 2 + * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< + * abss[col] = sqrt(d) + * return abss + */ + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_17 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) )))))); + + /* "Orange/distance/_distance.pyx":361 + * d += val ** 2 + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) # <<<<<<<<<<<<<< + * return abss + * + */ + __pyx_t_19 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_19 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); + __pyx_L6_continue:; + } + } + + /* "Orange/distance/_distance.pyx":348 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_cols) + * with nogil: # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":362 + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) + * return abss # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 362, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":340 + * + * + * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_AddTraceback("Orange.distance._distance._abs_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":365 + * + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_12cosine_cols[] = "cosine_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13cosine_cols = {"cosine_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13cosine_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12cosine_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("cosine_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 365, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 365, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 365, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_row; + int __pyx_v_col1; + int __pyx_v_col2; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyArrayObject *__pyx_v_distances = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyArrayObject *__pyx_t_12 = NULL; + int __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + int __pyx_t_17; + Py_ssize_t __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + int __pyx_t_22; + int __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + __pyx_t_5numpy_float64_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + __pyx_t_5numpy_float64_t __pyx_t_29; + int __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + double __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + __Pyx_RefNannySetupContext("cosine_cols", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 365, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + + /* "Orange/distance/_distance.pyx":367 + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * double [:] means = fit_params["means"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":368 + * cdef: + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< + * + * int n_rows, n_cols, row, col1, col2 + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 368, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":377 + * np.ndarray[np.float64_t, ndim=2] distances + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) + */ + __pyx_t_3 = (__pyx_v_x->dimensions[0]); + __pyx_t_4 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; + + /* "Orange/distance/_distance.pyx":378 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< + * abss = _abs_cols(x, means, vars) + * distances = np.zeros((n_cols, n_cols), dtype=float) + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); + if (__pyx_t_6) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); + } + if (unlikely(!(__pyx_t_6 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 378, __pyx_L1_error) + } + } + #endif + + /* "Orange/distance/_distance.pyx":379 + * n_rows, n_cols = x.shape[0], x.shape[1] + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) + * + */ + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 379, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_abss = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":380 + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * + * for col1 in range(n_cols): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); + __pyx_t_1 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_13 < 0)) { + PyErr_Fetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_14, __pyx_t_15, __pyx_t_16); + } + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 380, __pyx_L1_error) + } + __pyx_t_12 = 0; + __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":382 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 + */ + __pyx_t_13 = __pyx_v_n_cols; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { + __pyx_v_col1 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":383 + * + * for col1 in range(n_cols): + * if vars[col1] == -2: # <<<<<<<<<<<<<< + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + */ + __pyx_t_18 = __pyx_v_col1; + __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":384 + * for col1 in range(n_cols): + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< + * continue + * with nogil: + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice__2); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__3); + __Pyx_GIVEREF(__pyx_slice__3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__3); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); + __pyx_t_11 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":385 + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 + * continue # <<<<<<<<<<<<<< + * with nogil: + * for col2 in range(col1): + */ + goto __pyx_L3_continue; + + /* "Orange/distance/_distance.pyx":383 + * + * for col1 in range(n_cols): + * if vars[col1] == -2: # <<<<<<<<<<<<<< + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + */ + } + + /* "Orange/distance/_distance.pyx":386 + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + * with nogil: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * if vars[col2] == -2: + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":387 + * continue + * with nogil: + * for col2 in range(col1): # <<<<<<<<<<<<<< + * if vars[col2] == -2: + * continue + */ + __pyx_t_19 = __pyx_v_col1; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col2 = __pyx_t_20; + + /* "Orange/distance/_distance.pyx":388 + * with nogil: + * for col2 in range(col1): + * if vars[col2] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 + */ + __pyx_t_21 = __pyx_v_col2; + __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":389 + * for col2 in range(col1): + * if vars[col2] == -2: + * continue # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): + */ + goto __pyx_L11_continue; + + /* "Orange/distance/_distance.pyx":388 + * with nogil: + * for col2 in range(col1): + * if vars[col2] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 + */ + } + + /* "Orange/distance/_distance.pyx":390 + * if vars[col2] == -2: + * continue + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":391 + * continue + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): + */ + __pyx_t_22 = __pyx_v_n_rows; + for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { + __pyx_v_row = __pyx_t_23; + + /* "Orange/distance/_distance.pyx":392 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] + */ + __pyx_t_24 = __pyx_v_row; + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_27 = __pyx_v_row; + __pyx_t_28 = __pyx_v_col2; + __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_26; + __pyx_v_val2 = __pyx_t_29; + + /* "Orange/distance/_distance.pyx":393 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += means[col1] * means[col2] + * elif npy_isnan(val1): + */ + __pyx_t_30 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_30) { + } else { + __pyx_t_6 = __pyx_t_30; + goto __pyx_L17_bool_binop_done; + } + __pyx_t_30 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_6 = __pyx_t_30; + __pyx_L17_bool_binop_done:; + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":394 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] # <<<<<<<<<<<<<< + * elif npy_isnan(val1): + * d += val2 * means[col1] + */ + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":393 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += means[col1] * means[col2] + * elif npy_isnan(val1): + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":395 + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] + * elif npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col1] + * elif npy_isnan(val2): + */ + __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":396 + * d += means[col1] * means[col2] + * elif npy_isnan(val1): + * d += val2 * means[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 * means[col2] + */ + __pyx_t_33 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":395 + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] + * elif npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col1] + * elif npy_isnan(val2): + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":397 + * elif npy_isnan(val1): + * d += val2 * means[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col2] + * else: + */ + __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":398 + * d += val2 * means[col1] + * elif npy_isnan(val2): + * d += val1 * means[col2] # <<<<<<<<<<<<<< + * else: + * d += val1 * val2 + */ + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":397 + * elif npy_isnan(val1): + * d += val2 * means[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col2] + * else: + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":400 + * d += val1 * means[col2] + * else: + * d += val1 * val2 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - cos(d / abss[col1] / abss[col2]) + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); + } + __pyx_L16:; + } + + /* "Orange/distance/_distance.pyx":402 + * d += val1 * val2 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - cos(d / abss[col1] / abss[col2]) # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + __pyx_t_37 = (1.0 - cos(((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) )))))); + + /* "Orange/distance/_distance.pyx":401 + * else: + * d += val1 * val2 + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - cos(d / abss[col1] / abss[col2]) + * return distances + */ + __pyx_t_38 = __pyx_v_col1; + __pyx_t_39 = __pyx_v_col2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_t_37; + __pyx_t_40 = __pyx_v_col2; + __pyx_t_41 = __pyx_v_col1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_t_37; + __pyx_L11_continue:; + } + } + + /* "Orange/distance/_distance.pyx":386 + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + * with nogil: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * if vars[col2] == -2: + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L10; + } + __pyx_L10:; + } + } + __pyx_L3_continue:; + } + + /* "Orange/distance/_distance.pyx":403 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - cos(d / abss[col1] / abss[col2]) + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_distances)); + __pyx_r = ((PyObject *)__pyx_v_distances); + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":365 + * + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_XDECREF((PyObject *)__pyx_v_distances); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":406 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_14jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_14jaccard_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 406, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 406, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 406, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 406, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 408, __pyx_L3_error) + __pyx_v_fit_params = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 406, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 407, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_intersection; + double __pyx_v_union; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + __Pyx_RefNannySetupContext("jaccard_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; __pyx_pybuffer_x2.refcount = 0; __pyx_pybuffernd_x2.data = NULL; __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 264, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 406, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 264, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 406, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":411 * fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< - * char same = x1 is x2 * + * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 268, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":269 - * cdef: - * double [:] ps = fit_params["ps"] - * char same = x1 is x2 # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_3 = (__pyx_v_x1 == ((PyArrayObject *)__pyx_v_x2)); - __pyx_v_same = __pyx_t_3; - - /* "Orange/distance/_distance.pyx":276 + /* "Orange/distance/_distance.pyx":418 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == ps.shape[0] */ - __pyx_t_4 = (__pyx_v_x1->dimensions[0]); - __pyx_t_5 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_4; - __pyx_v_n_cols = __pyx_t_5; + __pyx_t_3 = (__pyx_v_x1->dimensions[0]); + __pyx_t_4 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":419 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -6051,7 +8129,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":420 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< @@ -6060,34 +8138,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNU */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_3 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_3) { - __pyx_t_3 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); + __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_5) { + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); } - if (unlikely(!(__pyx_t_3 != 0))) { + if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 278, __pyx_L1_error) + __PYX_ERR(0, 420, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":280 + /* "Orange/distance/_distance.pyx":422 * assert n_cols == x2.shape[1] == ps.shape[0] * * distances = np.ones((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): + * with nogil: + * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -6095,431 +8173,462 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 280, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 280, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":281 + /* "Orange/distance/_distance.pyx":423 * * distances = np.ones((n_rows1, n_rows2), dtype=float) - * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(row1 if same else n_rows2): - * intersection = union = 0 + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_10 = __pyx_v_n_rows1; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_row1 = __pyx_t_11; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":282 + /* "Orange/distance/_distance.pyx":424 * distances = np.ones((n_rows1, n_rows2), dtype=float) - * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): # <<<<<<<<<<<<<< - * intersection = union = 0 - * for col in range(n_cols): + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 */ - if ((__pyx_v_same != 0)) { - __pyx_t_12 = __pyx_v_row1; - } else { - __pyx_t_12 = __pyx_v_n_rows2; - } - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_row2 = __pyx_t_13; + __pyx_t_10 = __pyx_v_n_rows1; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_row1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":283 - * for row1 in range(n_rows1): - * for row2 in range(row1 if same else n_rows2): - * intersection = union = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] + /* "Orange/distance/_distance.pyx":425 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * intersection = union = 0 + * for col in range(n_cols): */ - __pyx_v_intersection = 0.0; - __pyx_v_union = 0.0; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_12 = __pyx_v_n_rows2; + } else { + __pyx_t_12 = __pyx_v_row1; + } + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":284 - * for row2 in range(row1 if same else n_rows2): - * intersection = union = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x1[row2, col] - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":426 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] */ - __pyx_t_14 = __pyx_v_n_cols; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_col = __pyx_t_15; + __pyx_v_intersection = 0.0; + __pyx_v_union = 0.0; - /* "Orange/distance/_distance.pyx":285 - * intersection = union = 0 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + /* "Orange/distance/_distance.pyx":427 + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): */ - __pyx_t_16 = __pyx_v_row1; - __pyx_t_17 = __pyx_v_col; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row2; - __pyx_t_20 = __pyx_v_col; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":286 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 + /* "Orange/distance/_distance.pyx":428 + * intersection = union = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - __pyx_t_3 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_3) { + __pyx_t_16 = __pyx_v_row1; + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row2; + __pyx_t_20 = __pyx_v_col; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":287 - * val1, val2 = x1[row1, col], x1[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 + /* "Orange/distance/_distance.pyx":429 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 */ - __pyx_t_3 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_3) { + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":288 - * if npy_isnan(val1): - * if npy_isnan(val2): - * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":430 + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 */ - __pyx_t_22 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":289 - * if npy_isnan(val2): - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< - * elif val2 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":431 + * if npy_isnan(val1): + * if npy_isnan(val2): + * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: */ - __pyx_t_23 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); + __pyx_t_22 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); - /* "Orange/distance/_distance.pyx":287 - * val1, val2 = x1[row1, col], x1[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 + /* "Orange/distance/_distance.pyx":432 + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< + * elif val2 != 0: + * intersection += ps[col] */ - goto __pyx_L10; - } + __pyx_t_23 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":290 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":430 + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 */ - __pyx_t_3 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_3) { + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":291 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 - * else: + /* "Orange/distance/_distance.pyx":433 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - __pyx_t_24 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); + __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":292 - * elif val2 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< - * else: - * union += ps[col] + /* "Orange/distance/_distance.pyx":434 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_24 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":290 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":435 + * elif val2 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ - goto __pyx_L10; - } + __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":294 - * union += 1 - * else: - * union += ps[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: + /* "Orange/distance/_distance.pyx":433 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - /*else*/ { - __pyx_t_25 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); - } - __pyx_L10:; + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":286 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 + /* "Orange/distance/_distance.pyx":437 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: */ - goto __pyx_L9; - } + /*else*/ { + __pyx_t_25 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L13:; - /* "Orange/distance/_distance.pyx":295 - * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":429 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x1[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 */ - __pyx_t_3 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_3) { + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":296 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":438 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] */ - __pyx_t_3 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_3) { + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":297 - * elif npy_isnan(val2): - * if val1 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 - * else: + /* "Orange/distance/_distance.pyx":439 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - __pyx_t_26 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); + __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":298 - * if val1 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< - * else: - * union += ps[col] + /* "Orange/distance/_distance.pyx":440 + * elif npy_isnan(val2): + * if val1 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_26 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":296 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":441 + * if val1 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ - goto __pyx_L11; - } + __pyx_v_union = (__pyx_v_union + 1.0); + + /* "Orange/distance/_distance.pyx":439 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":300 - * union += 1 + /* "Orange/distance/_distance.pyx":443 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< * else: - * union += ps[col] # <<<<<<<<<<<<<< - * else: - * if val1 != 0 and val2 != 0: + * if val1 != 0 and val2 != 0: */ - /*else*/ { - __pyx_t_27 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); - } - __pyx_L11:; + /*else*/ { + __pyx_t_27 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":438 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] + */ + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":295 + /* "Orange/distance/_distance.pyx":445 + * union += ps[col] * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: */ - goto __pyx_L9; - } + /*else*/ { + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L16_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L16_bool_binop_done:; + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":302 - * union += ps[col] - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: + /* "Orange/distance/_distance.pyx":446 + * else: + * if val1 != 0 and val2 != 0: + * intersection += 1 # <<<<<<<<<<<<<< + * if val1 != 0 or val2 != 0: + * union += 1 */ - /*else*/ { - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_3 = __pyx_t_28; - goto __pyx_L13_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_3 = __pyx_t_28; - __pyx_L13_bool_binop_done:; - if (__pyx_t_3) { + __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":303 - * else: - * if val1 != 0 and val2 != 0: - * intersection += 1 # <<<<<<<<<<<<<< - * if val1 != 0 or val2 != 0: - * union += 1 + /* "Orange/distance/_distance.pyx":445 + * union += ps[col] + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: */ - __pyx_v_intersection = (__pyx_v_intersection + 1.0); + } - /* "Orange/distance/_distance.pyx":302 - * union += ps[col] - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: + /* "Orange/distance/_distance.pyx":447 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: */ - } + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L19_bool_binop_done:; + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":304 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":448 + * intersection += 1 + * if val1 != 0 or val2 != 0: + * union += 1 # <<<<<<<<<<<<<< + * if union != 0: + * distances[row1, row2] = 1 - intersection / union */ - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_28) { - } else { - __pyx_t_3 = __pyx_t_28; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_3 = __pyx_t_28; - __pyx_L16_bool_binop_done:; - if (__pyx_t_3) { + __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":305 - * intersection += 1 - * if val1 != 0 or val2 != 0: - * union += 1 # <<<<<<<<<<<<<< - * if union != 0: - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":447 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: */ - __pyx_v_union = (__pyx_v_union + 1.0); + } + } + __pyx_L12:; + } - /* "Orange/distance/_distance.pyx":304 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":449 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * */ - } - } - __pyx_L9:; - } + __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":306 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":450 + * union += 1 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< * + * if not two_tables: */ - __pyx_t_3 = ((__pyx_v_union != 0.0) != 0); - if (__pyx_t_3) { + __pyx_t_29 = __pyx_v_row1; + __pyx_t_30 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":307 - * union += 1 - * if union != 0: - * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":449 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union * - * if same: */ - __pyx_t_29 = __pyx_v_row1; - __pyx_t_30 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + } + } + } + } - /* "Orange/distance/_distance.pyx":306 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":423 * + * distances = np.ones((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; } - } } - /* "Orange/distance/_distance.pyx":309 - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":452 + * distances[row1, row2] = 1 - intersection / union * - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ - __pyx_t_3 = (__pyx_v_same != 0); - if (__pyx_t_3) { + __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":310 + /* "Orange/distance/_distance.pyx":453 * - * if same: + * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances * */ - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":309 - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":452 + * distances[row1, row2] = 1 - intersection / union * - * if same: # <<<<<<<<<<<<<< + * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":311 - * if same: + /* "Orange/distance/_distance.pyx":454 + * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":264 + /* "Orange/distance/_distance.pyx":406 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ /* function exit code */ @@ -6551,7 +8660,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":314 +/* "Orange/distance/_distance.pyx":457 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -6560,10 +8669,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10jaccard_rows(CYTHON_UNU */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_12jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12jaccard_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_16jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16jaccard_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x = 0; PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; @@ -6589,11 +8698,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 314, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 457, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 314, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 457, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -6606,14 +8715,14 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 314, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 457, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 314, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ goto __pyx_L0; @@ -6624,7 +8733,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13jaccard_cols(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_n_rows; int __pyx_v_n_cols; @@ -6687,27 +8796,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 314, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 457, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":316 + /* "Orange/distance/_distance.pyx":459 * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 316, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":323 + /* "Orange/distance/_distance.pyx":466 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -6719,23 +8828,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":324 + /* "Orange/distance/_distance.pyx":467 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.ones((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); @@ -6743,27 +8852,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 324, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 324, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":325 + /* "Orange/distance/_distance.pyx":468 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.ones((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -6774,7 +8883,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col1 = __pyx_t_10; - /* "Orange/distance/_distance.pyx":326 + /* "Orange/distance/_distance.pyx":469 * distances = np.ones((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -6785,7 +8894,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_col2 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":327 + /* "Orange/distance/_distance.pyx":470 * for col1 in range(n_cols): * for col2 in range(col1): * in_both = in_one = 0 # <<<<<<<<<<<<<< @@ -6795,7 +8904,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_one = 0; - /* "Orange/distance/_distance.pyx":328 + /* "Orange/distance/_distance.pyx":471 * for col2 in range(col1): * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< @@ -6808,7 +8917,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_v_unk1_not2 = 0; __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":472 * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -6819,7 +8928,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_row = __pyx_t_14; - /* "Orange/distance/_distance.pyx":330 + /* "Orange/distance/_distance.pyx":473 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -6835,7 +8944,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_v_val1 = __pyx_t_17; __pyx_v_val2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":331 + /* "Orange/distance/_distance.pyx":474 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6845,7 +8954,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":332 + /* "Orange/distance/_distance.pyx":475 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6855,7 +8964,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":476 * if npy_isnan(val1): * if npy_isnan(val2): * unk1_unk2 += 1 # <<<<<<<<<<<<<< @@ -6864,7 +8973,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":332 + /* "Orange/distance/_distance.pyx":475 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6874,7 +8983,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":334 + /* "Orange/distance/_distance.pyx":477 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -6884,7 +8993,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":335 + /* "Orange/distance/_distance.pyx":478 * unk1_unk2 += 1 * elif val2 != 0: * unk1_in2 += 1 # <<<<<<<<<<<<<< @@ -6893,7 +9002,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "Orange/distance/_distance.pyx":334 + /* "Orange/distance/_distance.pyx":477 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -6903,7 +9012,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":337 + /* "Orange/distance/_distance.pyx":480 * unk1_in2 += 1 * else: * unk1_not2 += 1 # <<<<<<<<<<<<<< @@ -6915,7 +9024,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU } __pyx_L10:; - /* "Orange/distance/_distance.pyx":331 + /* "Orange/distance/_distance.pyx":474 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6925,7 +9034,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":338 + /* "Orange/distance/_distance.pyx":481 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6935,7 +9044,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":482 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -6945,7 +9054,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":483 * elif npy_isnan(val2): * if val1 != 0: * in1_unk2 += 1 # <<<<<<<<<<<<<< @@ -6954,7 +9063,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":482 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -6964,7 +9073,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":342 + /* "Orange/distance/_distance.pyx":485 * in1_unk2 += 1 * else: * not1_unk2 += 1 # <<<<<<<<<<<<<< @@ -6976,7 +9085,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU } __pyx_L11:; - /* "Orange/distance/_distance.pyx":338 + /* "Orange/distance/_distance.pyx":481 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6986,7 +9095,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":344 + /* "Orange/distance/_distance.pyx":487 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -7005,7 +9114,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_L13_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":345 + /* "Orange/distance/_distance.pyx":488 * else: * if val1 != 0 and val2 != 0: * in_both += 1 # <<<<<<<<<<<<<< @@ -7014,7 +9123,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + 1); - /* "Orange/distance/_distance.pyx":344 + /* "Orange/distance/_distance.pyx":487 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -7024,7 +9133,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":346 + /* "Orange/distance/_distance.pyx":489 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -7042,7 +9151,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_L15_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":347 + /* "Orange/distance/_distance.pyx":490 * in_both += 1 * elif val1 != 0 or val2 != 0: * in_one += 1 # <<<<<<<<<<<<<< @@ -7051,7 +9160,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_v_in_one = (__pyx_v_in_one + 1); - /* "Orange/distance/_distance.pyx":346 + /* "Orange/distance/_distance.pyx":489 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -7064,7 +9173,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_L9:; } - /* "Orange/distance/_distance.pyx":350 + /* "Orange/distance/_distance.pyx":493 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< @@ -7073,7 +9182,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_t_23 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":351 + /* "Orange/distance/_distance.pyx":494 * 1 - float(in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -7082,7 +9191,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_t_24 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":352 + /* "Orange/distance/_distance.pyx":495 * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< @@ -7092,7 +9201,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_25 = __pyx_v_col1; __pyx_t_26 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":354 + /* "Orange/distance/_distance.pyx":497 * + ps[col1] * ps[col2] * unk1_unk2) / \ * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< @@ -7101,7 +9210,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_t_27 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":355 + /* "Orange/distance/_distance.pyx":498 * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< @@ -7110,7 +9219,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":356 + /* "Orange/distance/_distance.pyx":499 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< @@ -7119,7 +9228,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":492 * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both # <<<<<<<<<<<<<< @@ -7128,7 +9237,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU */ __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - /* "Orange/distance/_distance.pyx":348 + /* "Orange/distance/_distance.pyx":491 * elif val1 != 0 or val2 != 0: * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -7144,19 +9253,19 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":357 + /* "Orange/distance/_distance.pyx":500 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":457 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -7360,7 +9469,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -7416,7 +9525,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * info.buf = PyArray_DATA(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -7725,7 +9834,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -8540,7 +10649,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -8608,7 +10717,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -8717,7 +10826,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -9498,7 +11607,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if itemsize <= 0: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9530,7 +11639,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if not isinstance(format, bytes): */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9565,7 +11674,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); @@ -9641,7 +11750,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -9925,7 +12034,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if self.dtype_is_object: */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -10163,7 +12272,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(stru * info.buf = self.data * info.len = self.len */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -13110,7 +15219,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview * else: * if len(self.view.format) == 1: */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -13930,7 +16039,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -14044,7 +16153,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__16, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__18, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; @@ -15348,9 +17457,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_7); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__17); - __Pyx_GIVEREF(__pyx_slice__17); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__17); + __Pyx_INCREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__19); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) @@ -15383,7 +17492,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * else: */ /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__18); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__20); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) } __pyx_L7:; @@ -15528,9 +17637,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__19); - __Pyx_GIVEREF(__pyx_slice__19); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__19); + __Pyx_INCREF(__pyx_slice__21); + __Pyx_GIVEREF(__pyx_slice__21); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__21); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) @@ -15654,7 +17763,7 @@ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -21597,7 +23706,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_n_s__29, __pyx_k__29, sizeof(__pyx_k__29), 0, 0, 1, 1}, + {&__pyx_n_s_abs1, __pyx_k_abs1, sizeof(__pyx_k_abs1), 0, 0, 1, 1}, + {&__pyx_n_s_abs2, __pyx_k_abs2, sizeof(__pyx_k_abs2), 0, 0, 1, 1}, + {&__pyx_n_s_abss, __pyx_k_abss, sizeof(__pyx_k_abss), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, @@ -21610,11 +23721,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_cosine_cols, __pyx_k_cosine_cols, sizeof(__pyx_k_cosine_cols), 0, 0, 1, 1}, + {&__pyx_n_s_cosine_rows, __pyx_k_cosine_rows, sizeof(__pyx_k_cosine_rows), 0, 0, 1, 1}, {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, {&__pyx_n_s_distances, __pyx_k_distances, sizeof(__pyx_k_distances), 0, 0, 1, 1}, - {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, @@ -21623,7 +23735,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_euclidean_cols, __pyx_k_euclidean_cols, sizeof(__pyx_k_euclidean_cols), 0, 0, 1, 1}, {&__pyx_n_s_euclidean_rows, __pyx_k_euclidean_rows, sizeof(__pyx_k_euclidean_rows), 0, 0, 1, 1}, - {&__pyx_n_s_fit_jaccard, __pyx_k_fit_jaccard, sizeof(__pyx_k_fit_jaccard), 0, 0, 1, 1}, {&__pyx_n_s_fit_params, __pyx_k_fit_params, sizeof(__pyx_k_fit_params), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, @@ -21668,6 +23779,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, + {&__pyx_n_s_p_nonzero, __pyx_k_p_nonzero, sizeof(__pyx_k_p_nonzero), 0, 0, 1, 1}, {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1}, {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1}, @@ -21676,7 +23788,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, {&__pyx_n_s_row1, __pyx_k_row1, sizeof(__pyx_k_row1), 0, 0, 1, 1}, {&__pyx_n_s_row2, __pyx_k_row2, sizeof(__pyx_k_row2), 0, 0, 1, 1}, - {&__pyx_n_s_same, __pyx_k_same, sizeof(__pyx_k_same), 0, 0, 1, 1}, {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, @@ -21688,6 +23799,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_two_tables, __pyx_k_two_tables, sizeof(__pyx_k_two_tables), 0, 0, 1, 1}, {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, {&__pyx_n_s_union, __pyx_k_union, sizeof(__pyx_k_union), 0, 0, 1, 1}, @@ -21707,8 +23819,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 21, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 24, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) @@ -21725,17 +23837,31 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "Orange/distance/_distance.pyx":23 + /* "Orange/distance/_distance.pyx":24 * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< * * */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); + /* "Orange/distance/_distance.pyx":384 + * for col1 in range(n_cols): + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< + * continue + * with nogil: + */ + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__3); + __Pyx_GIVEREF(__pyx_slice__3); + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): @@ -21743,9 +23869,9 @@ static int __Pyx_InitCachedConstants(void) { * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) @@ -21754,9 +23880,9 @@ static int __Pyx_InitCachedConstants(void) { * * info.buf = PyArray_DATA(self) */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or @@ -21765,9 +23891,9 @@ static int __Pyx_InitCachedConstants(void) { * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * @@ -21776,9 +23902,9 @@ static int __Pyx_InitCachedConstants(void) { * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or @@ -21787,9 +23913,9 @@ static int __Pyx_InitCachedConstants(void) { * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num @@ -21798,9 +23924,9 @@ static int __Pyx_InitCachedConstants(void) { * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); /* "View.MemoryView":131 * @@ -21809,9 +23935,9 @@ static int __Pyx_InitCachedConstants(void) { * * if itemsize <= 0: */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); /* "View.MemoryView":134 * @@ -21820,9 +23946,9 @@ static int __Pyx_InitCachedConstants(void) { * * if not isinstance(format, bytes): */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); /* "View.MemoryView":137 * @@ -21831,9 +23957,9 @@ static int __Pyx_InitCachedConstants(void) { * self._format = format # keep a reference to the byte string * self.format = self._format */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); /* "View.MemoryView":146 * @@ -21842,9 +23968,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); /* "View.MemoryView":174 * self.data = malloc(self.len) @@ -21853,9 +23979,9 @@ static int __Pyx_InitCachedConstants(void) { * * if self.dtype_is_object: */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); /* "View.MemoryView":190 * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS @@ -21864,9 +23990,9 @@ static int __Pyx_InitCachedConstants(void) { * info.buf = self.data * info.len = self.len */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); /* "View.MemoryView":484 * result = struct.unpack(self.view.format, bytesitem) @@ -21875,9 +24001,9 @@ static int __Pyx_InitCachedConstants(void) { * else: * if len(self.view.format) == 1: */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 484, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 484, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); /* "View.MemoryView":556 * if self.view.strides == NULL: @@ -21886,9 +24012,9 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 556, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); /* "View.MemoryView":563 * def suboffsets(self): @@ -21897,12 +24023,12 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) */ - __pyx_tuple__16 = PyTuple_New(1); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); + __pyx_tuple__18 = PyTuple_New(1); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__16, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__16); + PyTuple_SET_ITEM(__pyx_tuple__18, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__18); /* "View.MemoryView":668 * if item is Ellipsis: @@ -21911,9 +24037,9 @@ static int __Pyx_InitCachedConstants(void) { * seen_ellipsis = True * else: */ - __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__17); - __Pyx_GIVEREF(__pyx_slice__17); + __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); /* "View.MemoryView":671 * seen_ellipsis = True @@ -21922,9 +24048,9 @@ static int __Pyx_InitCachedConstants(void) { * have_slices = True * else: */ - __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 671, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__18); - __Pyx_GIVEREF(__pyx_slice__18); + __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(2, 671, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__20); + __Pyx_GIVEREF(__pyx_slice__20); /* "View.MemoryView":682 * nslices = ndim - len(result) @@ -21933,9 +24059,9 @@ static int __Pyx_InitCachedConstants(void) { * * return have_slices or nslices, tuple(result) */ - __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__19); - __Pyx_GIVEREF(__pyx_slice__19); + __pyx_slice__21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__21); + __Pyx_GIVEREF(__pyx_slice__21); /* "View.MemoryView":689 * for suboffset in suboffsets[:ndim]: @@ -21944,93 +24070,117 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); - /* "Orange/distance/_distance.pyx":33 + /* "Orange/distance/_distance.pyx":34 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_tuple__21 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances, __pyx_n_s_same); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 33, __pyx_L1_error) + __pyx_tuple__23 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 34, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); + __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 34, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":93 + /* "Orange/distance/_distance.pyx":94 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] means = fit_params["means"] */ - __pyx_tuple__23 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_tuple__25 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__25); + __Pyx_GIVEREF(__pyx_tuple__25); + __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 94, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":138 + /* "Orange/distance/_distance.pyx":139 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_tuple__25 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_same, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_tuple__27 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__27); + __Pyx_GIVEREF(__pyx_tuple__27); + __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 139, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 139, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_tuple__27 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); + __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 201, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":245 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); + __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 245, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 245, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":289 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 289, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 289, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 289, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":365 * * - * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: - * int row, n_cols, nonzeros, nonnans + * double [:] vars = fit_params["vars"] */ - __pyx_tuple__30 = PyTuple_Pack(9, __pyx_n_s_x, __pyx_n_s__29, __pyx_n_s_row, __pyx_n_s_n_cols, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val, __pyx_n_s_ps, __pyx_n_s_col); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); - __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fit_jaccard, 244, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__35); + __Pyx_GIVEREF(__pyx_tuple__35); + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 365, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 365, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":264 + /* "Orange/distance/_distance.pyx":406 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_tuple__32 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_same, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(3, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 406, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 406, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":457 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_tuple__34 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__34); - __Pyx_GIVEREF(__pyx_tuple__34); - __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 314, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 314, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 457, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 457, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 457, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -22039,9 +24189,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__36); - __Pyx_GIVEREF(__pyx_tuple__36); + __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__41); + __Pyx_GIVEREF(__pyx_tuple__41); /* "View.MemoryView":283 * @@ -22050,9 +24200,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect = Enum("") * */ - __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(2, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__37); - __Pyx_GIVEREF(__pyx_tuple__37); + __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__42); + __Pyx_GIVEREF(__pyx_tuple__42); /* "View.MemoryView":284 * cdef generic = Enum("") @@ -22061,9 +24211,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(2, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__38); - __Pyx_GIVEREF(__pyx_tuple__38); + __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__43); + __Pyx_GIVEREF(__pyx_tuple__43); /* "View.MemoryView":287 * @@ -22072,9 +24222,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect_contiguous = Enum("") * */ - __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(2, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__39); - __Pyx_GIVEREF(__pyx_tuple__39); + __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__44); + __Pyx_GIVEREF(__pyx_tuple__44); /* "View.MemoryView":288 * @@ -22083,9 +24233,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(2, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__40); - __Pyx_GIVEREF(__pyx_tuple__40); + __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__45); + __Pyx_GIVEREF(__pyx_tuple__45); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -22095,6 +24245,7 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -22255,88 +24406,112 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":33 + /* "Orange/distance/_distance.pyx":34 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":93 + /* "Orange/distance/_distance.pyx":94 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] means = fit_params["means"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":138 + /* "Orange/distance/_distance.pyx":139 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":245 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 245, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":289 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 200, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":365 * * - * def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): # <<<<<<<<<<<<<< + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: - * int row, n_cols, nonzeros, nonnans + * double [:] vars = fit_params["vars"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9fit_jaccard, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fit_jaccard, __pyx_t_1) < 0) __PYX_ERR(0, 244, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":264 + /* "Orange/distance/_distance.pyx":406 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, - * fit_params): + * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 264, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":457 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 314, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 @@ -22369,7 +24544,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(generic); __Pyx_DECREF_SET(generic, __pyx_t_1); @@ -22383,7 +24558,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef indirect = Enum("") * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(strided); __Pyx_DECREF_SET(strided, __pyx_t_1); @@ -22397,7 +24572,7 @@ PyMODINIT_FUNC PyInit__distance(void) * * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(indirect); __Pyx_DECREF_SET(indirect, __pyx_t_1); @@ -22411,7 +24586,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef indirect_contiguous = Enum("") * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(contiguous); __Pyx_DECREF_SET(contiguous, __pyx_t_1); @@ -22425,7 +24600,7 @@ PyMODINIT_FUNC PyInit__distance(void) * * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(indirect_contiguous); __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1); @@ -23509,6 +25684,48 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } #endif +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, @@ -23696,6 +25913,25 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in return result; } +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* BufferFallbackError */ + static void __Pyx_RaiseBufferFallbackError(void) { + PyErr_SetString(PyExc_ValueError, + "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); +} + /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, @@ -23714,19 +25950,6 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } -/* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(PyObject_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY @@ -24273,48 +26496,6 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - /* SetVTable */ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 @@ -24989,19 +27170,19 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; + static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { + const char neg_one = (char) -1, const_zero = (char) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + if (sizeof(char) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } - return (int) val; + return (char) val; } } else #endif @@ -25010,32 +27191,32 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 0: return (char) 0; + case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0]) case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { + return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { + return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { + return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; @@ -25049,83 +27230,83 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) - return (int) -1; + return (char) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + if (sizeof(char) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case 0: return (char) 0; + case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0]) case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; } #endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) + if (sizeof(char) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) + } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { @@ -25133,7 +27314,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else - int val; + char val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { @@ -25153,40 +27334,40 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, return val; } #endif - return (int) -1; + return (char) -1; } } else { - int val; + char val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); + if (!tmp) return (char) -1; + val = __Pyx_PyInt_As_char(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; + "value too large to convert to char"); + return (char) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; + "can't convert negative value to char"); + return (char) -1; } /* CIntFromPy */ - static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { - const char neg_one = (char) -1, const_zero = (char) 0; + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - if (sizeof(char) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x)) + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } - return (char) val; + return (int) val; } } else #endif @@ -25195,32 +27376,32 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (char) 0; - case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0]) + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: - if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { - return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: - if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { - return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: - if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { - return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; @@ -25234,83 +27415,83 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) - return (char) -1; + return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif - if (sizeof(char) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) - } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (char) 0; - case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0]) + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: - if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: - if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: - if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: - if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: - if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: - if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif - if (sizeof(char) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) - } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { @@ -25318,7 +27499,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else - char val; + int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { @@ -25338,24 +27519,24 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, return val; } #endif - return (char) -1; + return (int) -1; } } else { - char val; + int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (char) -1; - val = __Pyx_PyInt_As_char(tmp); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, - "value too large to convert to char"); - return (char) -1; + "value too large to convert to int"); + return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to char"); - return (char) -1; + "can't convert negative value to int"); + return (int) -1; } /* CIntToPy */ diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index 9d21fd0956e..062e212e585 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -13,17 +13,18 @@ cdef extern from "numpy/npy_math.h": cdef extern from "math.h": double fabs(double x) nogil double sqrt(double x) nogil + double cos(double x) nogil # This function is unused, but kept here for any future use -cdef _check_division_by_zero(double[:, :] x, double[:] dividers): +cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): cdef int col for col in range(dividers.shape[0]): if dividers[col] == 0 and not x[:, col].isnan().all(): raise ValueError("cannot normalize: the data has no variance") -cdef _lower_to_symmetric(double [:, :] distances): +cdef void _lower_to_symmetric(double [:, :] distances): cdef int row1, row2 for row1 in range(distances.shape[0]): for row2 in range(row1): @@ -32,6 +33,7 @@ cdef _lower_to_symmetric(double [:, :] distances): def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, np.ndarray[np.float64_t, ndim=2] x2, + char two_tables, fit_params): cdef: double [:] vars = fit_params["vars"] @@ -44,7 +46,6 @@ def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, double val1, val2, d int ival1, ival2 double [:, :] distances - char same = x1 is x2 n_rows1, n_cols = x1.shape[0], x1.shape[1] n_rows2 = x2.shape[0] @@ -54,7 +55,7 @@ def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, with nogil: for row1 in range(n_rows1): - for row2 in range(row1 if same else n_rows2): + for row2 in range(n_rows2 if two_tables else row1): d = 0 for col in range(n_cols): if vars[col] == -2: @@ -85,7 +86,7 @@ def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, else: d += (val1 - val2) ** 2 distances[row1, row2] = d - if same: + if not two_tables: _lower_to_symmetric(distances) return np.sqrt(distances) @@ -137,6 +138,7 @@ def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, np.ndarray[np.float64_t, ndim=2] x2, + char two_tables, fit_params): cdef: double [:] medians = fit_params["medians"] @@ -144,7 +146,6 @@ def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, double [:, :] dist_missing = fit_params["dist_missing"] double [:] dist_missing2 = fit_params["dist_missing2"] char normalize = fit_params["normalize"] - char same = x1 is x2 int n_rows1, n_rows2, n_cols, row1, row2, col double val1, val2, d @@ -158,7 +159,7 @@ def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, distances = np.zeros((n_rows1, n_rows2), dtype=float) for row1 in range(n_rows1): - for row2 in range(row1 if same else n_rows2): + for row2 in range(n_rows2 if two_tables else row1): d = 0 for col in range(n_cols): if mads[col] == -2: @@ -192,7 +193,7 @@ def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, distances[row1, row2] = d - if same: + if not two_tables: _lower_to_symmetric(distances) return distances @@ -241,32 +242,173 @@ def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): return distances -def fit_jaccard(np.ndarray[np.float64_t, ndim=2] x, *_): +def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): cdef: - int row, n_cols, nonzeros, nonnans + int row, nonzeros, nonnans double val - double [:] ps - - n_cols = x.shape[1] - ps = np.empty(n_cols, dtype=np.double) - for col in range(n_cols): - nonzeros = nonnans = 0 - for row in range(len(x)): - val = x[row, col] - if not npy_isnan(val): - nonnans += 1 - if val != 0: - nonzeros += 1 - ps[col] = float(nonzeros) / nonnans - return {"ps": ps} + + nonzeros = nonnans = 0 + for row in range(len(x)): + val = x[row] + if not npy_isnan(val): + nonnans += 1 + if val != 0: + nonzeros += 1 + return float(nonzeros) / nonnans + + +cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): + cdef: + double [:] abss + double d, val + int row, col, n_rows, n_cols + + n_rows, n_cols = x.shape[0], x.shape[1] + abss = np.empty(n_rows) + with nogil: + for row in range(n_rows): + d = 0 + for col in range(n_cols): + if vars[col] == -2: + continue + val = x[row, col] + if vars[col] == -1: + if npy_isnan(val): + d += means[col] + elif val != 0: + d += 1 + else: + if npy_isnan(val): + d += means[col] ** 2 + vars[col] + else: + d += val ** 2 + abss[row] = sqrt(d) + return abss + + +def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + char two_tables, + fit_params): + cdef: + double [:] vars = fit_params["vars"] + double [:] means = fit_params["means"] + double [:] dist_missing2 = fit_params["dist_missing2"] + + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + double [:] abs1, abs2 + double [:, :] distances + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + assert n_cols == x2.shape[1] == len(vars) == len(means) \ + == len(dist_missing2) + abs1 = _abs_rows(x1, means, vars) + abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + distances = np.zeros((n_rows1, n_rows2), dtype=float) + + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + d = 0 + for col in range(n_cols): + if vars[col] == -2: + continue + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1) and npy_isnan(val2): + d += dist_missing2[col] + elif vars[col] == -1: + if npy_isnan(val1) and val2 != 0 \ + or npy_isnan(val2) and val1 != 0: + d += means[col] + elif val1 != 0 and val2 != 0: + d += 1 + else: + if npy_isnan(val1): + d += val2 * means[col] + elif npy_isnan(val2): + d += val1 * means[col] + else: + d += val1 * val2 + distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + if not two_tables: + _lower_to_symmetric(distances) + return distances + + +cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): + cdef: + double [:] abss + double d, val + int row, col, n_rows, n_cols, nan_cont + + n_rows, n_cols = x.shape[0], x.shape[1] + abss = np.empty(n_cols) + with nogil: + for col in range(n_cols): + if vars[col] == -2: + continue + d = 0 + nan_cont = 0 + for row in range(n_rows): + val = x[row, col] + if npy_isnan(val): + nan_cont += 1 + else: + d += val ** 2 + d += nan_cont * (means[col] ** 2 + vars[col]) + abss[col] = sqrt(d) + return abss + + +def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + cdef: + double [:] vars = fit_params["vars"] + double [:] means = fit_params["means"] + + int n_rows, n_cols, row, col1, col2 + double val1, val2, d + double [:] abss + # This can't be a memoryview (double[:, :]) because of + # distances[col1, :] = distances[:, col1] = 1.0 + np.ndarray[np.float64_t, ndim=2] distances + + n_rows, n_cols = x.shape[0], x.shape[1] + assert n_cols == len(vars) == len(means) + abss = _abs_cols(x, means, vars) + distances = np.zeros((n_cols, n_cols), dtype=float) + + for col1 in range(n_cols): + if vars[col1] == -2: + distances[col1, :] = distances[:, col1] = 1.0 + continue + with nogil: + for col2 in range(col1): + if vars[col2] == -2: + continue + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if npy_isnan(val1) and npy_isnan(val2): + d += means[col1] * means[col2] + elif npy_isnan(val1): + d += val2 * means[col1] + elif npy_isnan(val2): + d += val1 * means[col2] + else: + d += val1 * val2 + distances[col1, col2] = distances[col2, col1] = \ + 1 - cos(d / abss[col1] / abss[col2]) + return distances def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, np.ndarray[np.float64_t, ndim=2] x2, + char two_tables, fit_params): cdef: double [:] ps = fit_params["ps"] - char same = x1 is x2 int n_rows1, n_rows2, n_cols, row1, row2, col double val1, val2, intersection, union @@ -278,35 +420,36 @@ def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, assert n_cols == x2.shape[1] == ps.shape[0] distances = np.ones((n_rows1, n_rows2), dtype=float) - for row1 in range(n_rows1): - for row2 in range(row1 if same else n_rows2): - intersection = union = 0 - for col in range(n_cols): - val1, val2 = x1[row1, col], x1[row2, col] - if npy_isnan(val1): - if npy_isnan(val2): - intersection += ps[col] ** 2 - union += 1 - (1 - ps[col]) ** 2 - elif val2 != 0: - intersection += ps[col] - union += 1 - else: - union += ps[col] - elif npy_isnan(val2): - if val1 != 0: - intersection += ps[col] - union += 1 + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + intersection = union = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x1[row2, col] + if npy_isnan(val1): + if npy_isnan(val2): + intersection += ps[col] ** 2 + union += 1 - (1 - ps[col]) ** 2 + elif val2 != 0: + intersection += ps[col] + union += 1 + else: + union += ps[col] + elif npy_isnan(val2): + if val1 != 0: + intersection += ps[col] + union += 1 + else: + union += ps[col] else: - union += ps[col] - else: - if val1 != 0 and val2 != 0: - intersection += 1 - if val1 != 0 or val2 != 0: - union += 1 - if union != 0: - distances[row1, row2] = 1 - intersection / union - - if same: + if val1 != 0 and val2 != 0: + intersection += 1 + if val1 != 0 or val2 != 0: + union += 1 + if union != 0: + distances[row1, row2] = 1 - intersection / union + + if not two_tables: _lower_to_symmetric(distances) return distances diff --git a/Orange/distance/distances.md b/Orange/distance/distances.md index a298f46bd92..9aaa4123ba2 100644 --- a/Orange/distance/distances.md +++ b/Orange/distance/distances.md @@ -2,7 +2,7 @@ This document describes and justifies how Orange 3 computes distances between data rows or columns from the data that can include discrete (nominal) and numeric features with missing values. -The aim of normalization is to bring all numeric features onto the same scale and on the same scale as discrete features. The meaning of *the same scale* is rather arbitrary. We gauge the normalization so that missing values have the same effect for all features and their types, and so that Euclidean and cosine distances are nicely related. +The aim of normalization is to bring all numeric features onto the same scale and on the same scale as discrete features. The meaning of *the same scale* is rather arbitrary. We gauge the normalization so that missing values have the same effect for all features and their types. For missing values, we compute the expected difference given the probability distribution of the feature that is estimated from the data. @@ -91,19 +91,44 @@ Same as for Euclidean because $I_{v\ne x}^2 = I_{v\ne x}$. ## Cosine distance -Consider that Euclidean distance $\sum_i(x_i - y_i)^2$ equals $\sum_i{x_i^2} + \sum_i{y_i^2} - 2\sum_i{x_iy_i}$. Now assume that $x$ and $y$ are normalized as described in the computation of the Euclidean distance, except that when computing the distances across the rows, the normalization is also done **across the rows**, not columns (features). In this case, $\sum_i{x_i^2} = \sum_i{y_i^2} = 1 / 2$. Thus with proper normalization, cosine distance can be computed using the same formulae for missing values as the Euclidean distance, and then converted by +The cosine similarity is normalized, so we do not normalize the data. -$$Cosine(x, y) = -\cos\frac{\sum_i x_iy_i}{\sqrt{\sum_i x_i^2}\sqrt{\sum_i y_i^2}} = \\ \cos\frac{1/2\left(\sum_i{x_i^2} + \sum_i{y_i^2} - \sum_i(x_i - y_i)^2\right)}{\sqrt{\sum_i x_i^2}\sqrt{\sum_i y_i^2}} = \\ -\cos\frac{1/2\left(1/2 + 1/2 - \sum_i(x_i - y_i)^2\right)}{\sqrt{1/2}\sqrt{1/2}} = \\ -\cos(1 - Eucl(x, y))$$ +Cosine distance treats discrete features differently from the Euclidean and Manhattan distance. The latter needs to consider only whether two values of a discrete feature is different or not, while the cosine distance normalizes by dividing by vector lengths. For this, we need the notion of absolute magnitude of a (single) discrete value -- as compared to some "base value". +For this reason, cosine distance treats discrete attributes as boolean, that is, all non-zero values are treated as 1. This may be incorrect in some scenarios, especially those in which cosine distance is inappropriate anyway. How to (and whether to) use cosine distances on discrete data is up to the user. + +#### Distances between rows + +For a continuous variable $x$, product of $v$ and a missing value is computed as + +$$\int_{-\infty}^{\infty}vxp(x)dx = v\mu_x$$ + +The product of two unknown values is + +$$\int_{-\infty}^{\infty}xp(x)yp(y)dxdy=\mu_x^2$$ + +For discrete values, we compute the probabilities $p(x=0)$ and $p_x(x\ne 0)$. The product of known value $v$ and a missing value is 0 if v=0 and $p(x \ne 1)$ otherwise. The product of two missing values is $p(x\ne 1)^2$. + +When computing the absolute value of a row, a missing value of continuous variable contributes + +$$\int_{-infty}^{\infty}x^2p(x)dx = \mu_x^2 + \sigma_x^2$$ + +A missing value of discrete variable contributes + +$$1\cdot 1\;p(x\ne 0) = p(x\ne 0)$$ + + +#### Distances between columns + +The product of a known value $v$ and a missing value of $x$ is $v\mu_x$. The contribution of a missing value to the absolute value of the column is $\mu_x^2+\sigma_x^2$. All derivations are same as above. ## Jaccard distance +Jaccard index, whose computation is described below, is a measure of similarity. The distance is computed by subtracting the similarity from 1. + Let $p(A_i)$ be the probability (computed from the training data) that a random data instance belongs to set $A_i$, i.e., have a non-zero value for feature $A_i$. -### Distances between rows (instances) +### Similarity between rows (instances) Let $M$ and $N$ be two data instances. $M$ and $N$ can belong to $A_i$ (or not). The Jaccard similarity between $M$ and $N$ is the number of the common sets to which $M$ and $N$ belong, divided by the number of sets with either $M$ or $N$ (or both). @@ -124,7 +149,7 @@ $$\mbox{I}_{M\vee N} + p(A_i)\mbox{I}_{M'\wedge N?} + p(A_i)\mbox{I}_{M?\wedge N Note that the denominator counts cases $\mbox{I}_{M'\wedge N?}$ and not $\mbox{I}_{N?}$, since those for which $M\in A_i$ are already covered in $\mbox{I}_{M\vee N}$. The last term refers to the probability that at least one (that is, not none) of the two instances is in $A_i$. -### Distances between columns +### Similarity between columns $\mbox{I}_{i}$ will now denote that a data instance $M$ belongs to $A_i$, $\mbox{I}_{i'}$ will denote it does not, and $\mbox{I}_{i?}$ will denote that it is unknown whether $M$ belongs to $A_i$. @@ -149,7 +174,7 @@ $$Jaccard(A_i, A_j) = \frac{ N_{i\wedge j} + p(A_j)N_{i\wedge j?} + p(A_i)N_{i?\wedge j} - + p(A_i) p(A_j)N_{i?\wedge j?} + + p(A_i) p(A_j)N_{i?\wedge j?} }{ N_{i\vee j} + p(A_j)N_{i'\wedge j?} diff --git a/Orange/distance/tests/calculation.xlsx b/Orange/distance/tests/calculation.xlsx index 13e4879608125e703fe59c9852f101764a0c768e..47fa16221232591a5b3c0591c1bf97a1b3896ddd 100644 GIT binary patch delta 42628 zcmbrk2UJr*w>BK4gY;fQFVdv<4!fDi=*Y0{-iReDEy2LUMw zO?pBNE&1a6-tXRZ*ZtPL|9yXQX02JnoH;XlX7By%XHUat!k%a%RwF$^B1RAihztY* z@q)agu9R{KKp-&XH`bfi0H0+|x$BZfQXlRHznfz0LDY5n8tw zw6y;@?u6s*dVK$4yT6OKPJ{m~nbF^5#U;sVnhQSX0*7y0+TV{EB@@GB*tx+}nas>V zkyCT2dDQK8CR_egREIylWqUfgKJL8M(hzIi<5YTWPArzPKb|`KjxbQeZm;zHjcA|= zZ)3*Fh9G$g{6*7cMePmpYIB|8YoX)5spVx}*_V+Wei9*LJ}p0AmA*x`q)caB?xI|C z&ewR->uSHhF{M#55GJ-~Snp7WzRMV9y1MCp@@!Ci>GvG_ZP^T6>JC&rNnuLh_G@wo zVfei@&mj(>W5q)f9Hts5^xWiT&D)it*#9}E7rr7#mr#9IX_x`={XzJO3|&G9AE!mk zOYb;SEo0?JjX0k?k|yk%o(*huw2aLjJ(!u|GRI?5q+#fXBX!sFm#pupsZl0@l%!6v ziO{Ai8ny5bdqTil0S2eiUagHMey{ger_BAtDc(@ho6kaR6Rec!p0WRKeD1tb0Q%OG z-UCy;B&zNud`L(k^60?C62D89GL&N-x8j|?@f@DEri#^WHgiZH~sPC*qc@c+cB& zEDnvZ#2^q3M+o}Q$}uN?2oWR%fpSSfAR4^7z+OoCdAx!?13WySk}$Uyd1mwOD+;v1 zQk6I!luwS4ALNNY;+M2*wsTmwU8YNH-FJkxo-s6E8`sP)>dQzeI=&Yt8mrMM>ook9 z8O$!)1Rk_3H%sV92l+pIWc$)*aBRcS28dPLj=m8+8oTx<$?E9o*%jw+USz6=E$ zKT%2)63X&(TVaiFjJ^vi_bXn1$$BCx#X>6iE7i_7(G-~4zgt&Nwo3kN!M2@C?A7~r z^Q>QSECuE6P|0PvH2bHoQ3uAcfrK2(&GZRu+MG7fHLU{SH-LGvHxG9zd$ zLM(@9LdV~ z{l+!&L_Ts6!U=BrM=Y7?j@qTZAD_Y4KFwB_{I~--vn3EFTwY}gF|{fGrPV$Ql4~YW zXMz%i8f$ueZcdqDRS>uENPQXuan>Yht?c~?ULwoyVhkI6(xo|HEK91vkxYMUKYm8C z41F7@dZ-8$?;urdVupc+@OEAIIkyWU-ojSOFU_BzD7cq**S1g1^$O(Lgye6hAISp0N!Wg6 zxqrD6Fj;4lnd{CXpqWXXIso$nG0}`E^oQu?7kslhkLwNoOhjXYx?q}bKPa+kk(=EA z;y_=BR;kvq)l{t6te!bN&vucs)LwoAyk2n&Vvg9R~np<@vW^LqVz;AmV9}qD?Wb3&lZW-GPcwaaJlI8Polm zMz=lr4$q%A!SxO+&XtUMy^LxB+=yE^wzrR&$8{w0eKzG%lN-E+@}Pt}I*PaG%Lh4U z*^VpNe$nZS20V9t%)Uair;Wo_G*&dDNwK6qSdV6qD7}~AGAwjRo-OG}HotABK@O+Y z0D{#Gx~iKeth~Q(apx->7nv*p!B;2lv0S$w&v?@MD*324{$3ze(=*!jd+n-cBxPpm zC2e9fl>gwC*#l^ixf)5^<-xXI_&Ws=K%1Bz9g!N^Ae}dSj6JC8XR! z)9-Q{Npwy4VHY`EM&jZ78Z9;_YNyXH!$sB~L^OLwRz4QePGTNj6}A6a{m75lF&BM0 zyMPHG(HR1(_KFw0)+m5D2djREWOo@p0PiMG4#%8G5@7 zD%_Pt_ekT-eIxmR=eOtXXz9!zGUxN0Zrsm*XC25;T$6EZ+gGsm8LG5#4#21d^0<{~ zdJG5tq?zY#m!aNewDV~?PNoO*tiHM@g(dju(Co-uqMjhzXsXex9~aMas@bk;C;kQR|8Zk%Gmkoeb$$qs~Oyrr>pN;b-xSGK%$Ytqmd!w8{di7@VL_BowPv za@d2$1AQp%7LvaZMowBH(!J|fIlkTH@_CWUKjLXC;(d;Vn{tdwwnzX^YRenKI4hac zc(6_M(39ciX@zLJc0#6wdgkXP1ckmonhe|JyF(?x0fsbb24oKh=bu&21^Pap`m?wy z;eLztiCNIC?j!elpIx1Qk?l>{ zfKlIjA16|`+wXZyvE7_2^_cd7Q`*J#p9C5?I&H#p6`U=){ZOOYoZ?@B?xVgtn#7r< zarOEGloZSxKe!QHk;vD!p=!SsvfuqyujjRDbCr0^c$U>KLThVJZ6UZxV6&Bo9MLza zJ=*vsEOMOl+{a0Crm7WKWv?cX(G{)F$q7T|RFvN&QnM>iYn3&9TKk>!#PN%)(Ef|~ z!=ZSk)*Pd>e74Y{Dn;fpPczlQK9wzPllpM%&ieOm1!?{vLNb|MQK@xiivvDk$w4G1 zjqD9a*LZrk;oU>4HD1_tP13&SHHPtS-%}1B77^-bpu)*hUF^{ow;n3n7PZrOrgS&1 z%##Ss@jjHwnOBVW;dJU{iDu0?)fmjA?%`Dm?+ZSnB+m=Xo0NSI>t_PAI5a)A7HH;q=J;q^ zC`**qhe6Q)Tg80FXHx*u_hqb1a)`1>a@0YT(({G`vpvD29NUKmg))mjK5jiBG+*mH zzF(SdOC3)xUVGhGD3p6ra;j|cQt%|KuV_?PF_S=s$I`xH(qFJa*ltaCnB7Gx#b0o$ zu5qVd`D5e84RZZzLt^s;gS0+pDwe%K3(R{de%DXXCzKNJbr(=Tf`s+=n{2mQImRYU zl+eDt;CeBTO<1h&>)&2ZnRaq#3b7Np*WLso?ByngI3v4S3K?Ktel9Y`U*xo!lH&5O zJdP-^!!^>`n((p5>y)+|{l4QZU7k9ux;I^WTC75+_iOne9L*-NZRSA9NwuI>Xfwzu zYj;&mYJHbPql64_g6su!_;kVher#JCjoubHZui}Uti{*e^`vR=H3>LwNHbp_3fc*K zRC~u4AnX63y5pUzO7O>zDK`5uk<$OnHNS3udg`H^iIdC1{BJW=4QeL~gF>2(R?#0t zVoxR5qBkg-JZk77JR#Sd6!wyZu~~hcLD@7`K!|mg6<`SfH&5OjN8x`Pt%r)RAT$Pv z?p}d{i`0CYI!~f@Y39LonlFF`9q~-uk0ovy@OtNAi5l+m@e<|V_Fve_tEU$eXC<7i zUYEmY)!zMoRJLszx;1vdRlrXy??n{Nx2PS>YTO`J_G0AUD_jI8S+js6fctdi)TF+O z30P1J^HNTyi z?EM6)q=J!hvkxD>vn(DUM@abax89~;PEYD{cCP_SA z)&+-le}Lo>c}mMAsnA>OFi?Y*_jw@qY^$%nr&&k zPx0Umf5W7?uy9Sv!$nV=OefaU&e?5i)8@si1Tl!E*+Nc(pCqo2+P_6fuV ziwVdV&dbeS;=^SN2{6R>t zK&wVF1l;HGdR0;Dfa6Isi$E(u@)B*INA#-V-2)E3GpeLZ8G+X8eNuN01}gVtrvd73 z)ZWp@*>_4Qxt<08q2&sH!uzEYp!MbqrM_F4^x){H(Q3wmnhuvlmJ$X3!lFu4tzjkY zvliu@)73rp#)ls>;ZDw7-`Tci_ONuKTwzH^cLS30EoN9;4z{+=fq=9KPs~YC*Ljn%dx^O9&UawnMg_;4 z?D)r&wvK7N=c9)e$Bb5>NuY;zYjYCS`+MupLrzy;?kl@qKC(bA)UB!&++-Kx5npe4 z`Cad6Z4l?Q}wk7)C<4l zwCS`^UFeVURjcI3eRE1gNf*?Ba>OAeEmuSRu))a_Z*uFTiP+J7o~liYCvFSPddsKdpra?a>P0y z82vvu&}EDk>A&8j`(Fm*tPi`STW-t{+S5xUgW37BbZaQTvGbtWG;U~zu0UvQtUK6t zEu+iIa$*;0q%_7>Ds+t{_>2X+HSTh)RugFBecr z{G>h{mOmnwE^qT^BB*L!wrZT~`(GQfcWxBIqGqJxL(!_}lb zyxb7MA%TI>YMS|X)EGMRZTlEU2e^uoMV}>^tt63o`&`evN%C3~M=%aIl4JpTnk2FE z^qB9?by())UMxcvqnn%Yp?U27;Dz7N4+(L{a3O`=&XnQhfNO1BkWXk?Y_J+74iv_P zm*0mPkbf3~=Eg)@D@J+-zYZHM(*I=-W&9ungD`C@Z~Tq@os^dA(m;pdidzp72YPI! zF&^Ypk>2)2U47=K&4{|2WfK29S(=%S)tHtF0H5QPgKzT+0P&a*9Eg@Q+&in%8lzk$ zTjYOl@4`ke@r=T5|B#tWeT5Yc(=UCMuG2~Xm0t-rnjGsE)XKpoPEk!ov< z$UF}81aDoOWS6!}l*2AGmilGI1HA54eLVSeO_nDpLhz+CVc;O<6Aq-2NsI%vC$!=~ z{c|9-k(jK*&1J|X>o#5m$}F=9|HnSr)J{DWXc{c-67yBnOncm4LonQYQc%}A!@g<* zIN18HFE~t03w_r9-c=>jV?W0gnrsSR)?|mr2?WBI1sDK=0hnr!23`HQ`#8XedBx(v zh*@{g@fng-xcM71-^Idw5D}O!Bo^oYERzj1D=u?i+#zY|BVjQP6u#0994TTTI1mMu zFb+H|{#sMGtV42qZO>NVf||oBownn7l!4J z$w#lCog(d%^~H=Htmp^o`uPRwm_1^0kCT<9{rXi#r>#$pz@j5W1{KcDjGAPCRdl`_ zqJERBEhn?x@c31?cz_R3rNf!jJnEgq%H;io&62i_E*7-(FYM!gyN#*n-nT*gUdt7% zHuIR0PWW#_1VDR-h;}>eF=w^DT!a3cHsd3~F@M3NUjm-ll6&o@^jg_8xXHhEP;@wm z?&GTAi_RSICRSwQ3CJql4rw0y4x+|hJ zcrd|euM-=T`-kNvB3BIx%m&(|NAr4xF~tej61RhL|rxoel36%B&9Q7u{atFY?cB1-FyF7Xf*G(BIa zQASa0QP`I+5v-K4pl!`6xWNr|fPZDFhlU{tjA^`3f`#;Uw6L{eJkfqg`NU2Li>q~1 zXp_+rDq#s0W;kPUYia}Y!Qqt}6N215NZ$rn57v zW}{syJd7@nM)cJX4tVa7aS)G^SkTlSo6ACdcrM6;JrZdD;;5h11~Ku7Pz}O51d7e z+XO7^3ZcEcUwr9wRnS5S<)%TIXCS0N*x@A#tT2Y7D?oeq>NMuK4wK=J-srUBP3&e? zwAM&3_#=_$+De`*LEU@5Vdmk9OvbYdtAq_>c9Kv6xPc@;cv}NpU4uVq+ua0DTT#=w z#g9oY{08->T4Rqs&OVrfzmqfud{$^e14z51=rG_O4GmOc+Y%?N5s^?CbO$xlZFdtR z=75CIU8>LYN2qMPIUaKA_G`!rKMwu+)kmFV+pzgYHrq!KBcWIONv52e(9ZlemL*mb zqZ{;!%@LJQqWWp3r-jF+n6NOutfO20XNo1SboIOzdcIG6qU%)lwT~veO_G;@6fS#{ z7a)y<4RmUfyK6{Ys!X-;EMW&tf&wEKy)pVluwDcX6eWPEOR0l?{nXnz9}n$y>bb@t zH+j6U(OGIfB`;y`DA>}<@Y)XtqLB!)U!)mlpRhv>GOuoFJhsqam~t<8>{{P`Is%S& zqdV34k;;tTxn1N}mHLEwVkblukE9dfdN;-4Nm2{|Y5{`i?Xc2Nf%)|W97pZ6;XpOr zGm&rY7|?bVsKQQt^!Q5qA_sOhCKt8W=)aT@QExltAtbjH|aG4`v*(&-uvC8HA=-N`R{-j+iAw4Li z_lI_$P^PEs|5-XDc0Zg}JikCmAhZ~>6?VI9`v;d?B|ST#O8btbY;LKh?SJx>zI`z8Uv0q0@q<)%0q{RpQd_OrG(lM zUe^sM#mg+Xj^EyM(Ibzkh$>Ei-4E^5BaJHByl3gBQtMzR^WlN;tw$Bnm^}vM_0woO zFB>^TYUf!9rF@UWtOj45J=(H#E0UBYro(J7lXwlI?0~T@4;KzU`2ZbZVC&CUMSQq^ zPi)8V8-{Kl8>vYSAXrL)!(hn6;OJoZXGwlMvQb>*N3DMV$}v&Bnlwie47#-`r>4_B zS=X0b0?gALuI;7m;Xp>sm?+}>jM5vFdY+zgp7)v>K_Z0f@lYKM;}Shq657CAc5&l( z$V9y+RjnHs$(@g=Acm=c=h#o%8x&$FZ+*dJSyZFTX1eHdHm9pMpY_b!By8(W7*htz z+^v?DZ@5W{oBnI#DSOq#Rx~M{t1u0{aI_2y;Iq3#>P%{d15paMWgW@6Ku*tEF$*9t zsw#*a2fB0b0}ceF<8AjSKFaxDck$w;!@OB;w7sz>mPof*`EyYO-Q1r$*!EFM&81>t zu3zI0a4_PgW^ykuFBUc|LRg3cMZlL0&)MZFE-sfY-SHuTmB!yFGFKM|Y8}FXdj2Ax z|EUY%N@83H_q5uri+e%hn0i!oHRqt`Ch2o8XhpR@0Uw8MRjAeRJ+Xb!Wor|9PVLwE+L)Vh%5QHOY@@=&{oQ z7TxJm%$FiSlrd~&xxNd!&*aL@KZC$jBlKFs7O!EZme(=C2t(>S%jpZ0MySHr0!&J( z$+n^qR%`l5i3bntWKdc)}T$iqvMg4hToK>H5!=F;KT5_u~@`PF}QdLG}z^EI#)|O z`PF=QWa=N3@(gtP7Yen~UNX2L0IK;Bq^*qT@~Ah=F}~o**Z_0Zi)4PPsOt&&5BgSp zl!ibaaCdnr04$E358zI{xQ*=xgEh!uLXdDfL3C<2O$1g3r5VA8`Bvd-O%qz9Ne9c) znv}Bz_b4{h!Ix=b*vm3b!#pao(FzIY9ublrStb(_&ud%89qlJ~LDC*_4}6wlGnFuF zE4vUxcX{s93ng#_G_6dn;+$@j+HX+SSlAToFeaWj842`+h$1)iqx5(vP2KwI==l4B4TDnXjx@ZBT! z)hN-a5cGbe{6fIK#Z+o{nn5ihE0S9d6PI6}^yN-|dBWV|F^r0y?H!}0>GejZ)(37i z(dG*k4xpooNZ>%=PphpV4rIu3M6fVQphb*F8i&)(Xq%oi#a%;G=W@~Ck1QcJx@g{H z0c|IT~di}~pv|hGuQyTCOnD(}iZQ7ClNOTXRen{_;W)K_{Qmo7&ztPm0B-aj z0@hL@l7NLCKv)b5F&!88>ot_ox8p>-l{wweao!k^G7 z6(#s%Wk%r4Vu`3)vq)w_F!4-G5jlu%ppV5+!}`0f^MT*W4*Jk z!StIH(HfeOAv~j47Fcdqh}d)ugvQ0s1eV^Z60x?I`<(Grl_AGX(iY5pE%e<6v-vwK zL-(dgV=mn|?xnFr*;9#Y$j%@$mungVE1^He^{DIL(lHv!YE$HiL}znp!abC90kC|K z@hFx^ss|D}76h4A{PPmn-&RlYCD(=6J~+xjV>>%b=lns5=JZFKy3{P8Ot;b z&`}rbu&++BhlfaVCyfcMivHXdBA%tqfP6|8%6Fah3i z?!^IRF-{Y6=8K3t)nB{frX){q$AWfR|3gBJ-HY59PEF^fNU4=z!wyAoP3atW*_R+b z^l5Ym3C7^GhdJ#<10+_>umr>34q>ebB9|{u`nre#I_>1pkMSTzZiICXdY&332WEhM z@+LoWQ#5IfCY)63OD*Sky<)I`9A^22=3GCL%b=?>4qSAGqc-ZO`{fC?V)(wfg z{9MVjmp;@4#{G9BU**xIfr=3xG?)Uz>#$c3f`W_YyM@AXo6NVfF|V{k6(@FQd94H| z(yW*Tc?o|G?yz_zccpwKS+2vk?4kvV=VjC%2JOnR^N{SGOT%@%cZedjJ^ryc#I1M0Gs`5DSKAqP3cquMcNk$~mY zslYrpM4RUaFY7_rVWP)FvUjjcqakwy@OPYS(s87d=uvq`LfraW=;5pZ4)7%Vb z^Ah)4Ep6S4skwG@vO$F+)hUETMb~QxX5eUbeP9Jb*Cd-4q=Uxu9fl09=M`~JQHkyQ zjIb~y1B^?93A5*b_UK|$lMX~k5p1)USI)h7dH)NHy0@!EX66ZMr-A#+Tw;PCN-ECH z$Cm!EO#ubv;o1nhgygm7E#%I@ay~VgtbBSC)y^&VLqAnR9!=c!q|XC!_T0)`+05w; z%|}D1Qu6e=Qu(tqk=H6&a8LF7fCdCpvTVp4q=VT+sUrD;v=Rmo_uCuiml#^x7yM4# zF=a@~CA!N8&GnPsVnDR$%7SdqB13KEWRS%2F2riAiSElbHxb$?%3IwFGS%c(?9#%6 z7Rp%G%OZRo=+rsFylLJ-GtQGT(KYkPlgd^1S0I+C~HpavYO^Ju04Cpxz)~&SrQ7y!aurQN}AVC)tWW}sE#%H^N zK1dA{vrJ`T*o>wcc{|dXuFt&|VV%+V0R#!X-pQiE(GCM(e4mkR&qHXpo?5yR>sB%97riv?Dfo(qwLl z%E{<3#zn=?QdHx;HdvtO;8%i-_ydYyW9<(F*n1*@7Ed9FXI<#VBlWOUvb<2mMP4oIBP*5&v z;zVUM%n6K!gSx8t6{s-1N(o zpAMn6#FW_7VeS+XDt2Z?Kqz+An*A)B(LVdJwXCJJdRjENe^9=Eoi~61pVVS-AS47I z8L?_Qcu>PkdgpB4X3=49!Z_OPBr!gM8=aH`S5EC%MRY>^@<4`v6H|$ua8E0}eC=X+ zaULEylDn;pV!`=Q(LupzN1G)AjF)k>7EM(X0}jLkUAo|C;Q_Y%k-DJmA`sqXYRUpm zG;@h}F|D~FF0^=)n{Oh$2#LRL=*Qxlprx&?fxjaxX5x;`3 zV+POx+cu+E4Vz!CcI+63!docWP8^8)m`fNr(&Yifuz<;rfjBU^WDsv2tOY`YfgnH_ zPpPg9Cj=SlXpszU5Qe^Qf~HO{!Z>xF)~h&^Ze?|9p3!?l%JE3OFzy_*_vi1jG~};J zHPn7zQlkxbs@X6ls1?LX3|jFdbhL#NlY1Lo^=JBgBtcH!*#pQRQ;mBe4paRHZdQ)FLx#F#4LalS0aW z#&V&}BPD7ncW+M;?(Rq7KnJ|=X+>kWmjJ6YJ|sfSm)(P~JnlxeGHgBw@9o5%9S#U9}hvxn)2^zeYvKY@5Fe!|sXNg12>`F!JckZD-#UZ`)Jvqb#D9tf%Dm3GH0$=xWf0@jkmW?RLz~Xxoz*2V@1C>zrTs z5oNqy7mJb0Ai+F5PU`_s;fMHCDj``>p}`9qUmWjW3~Vf3{ejv~C9Z99lRMNUIIfig(7Ll7BEugW6!>2o@%4- zM>d%)+j4ZPaQ_f&Dal=MNfXM?wQ-%BDsRlTb)F80Z)wc!3m^a>rkD+sjSgBqE6hDa z6*Ilx)sPs;(4FQE|MJHolRwpXVguz7-NO58QzfW@v@^qC`l4s9_jM32GK>9>CbfiP zDv~BzO%$>Fyo+5p(&MO1Wor{8qsDb{_mUd(rUK^InMsEkLPM<4!qLZ4^nX%R?gCUn zF3_(oel3hs;uhWjgEn#=kKDo);24q_{i(g3nv3*(j*6(GGY>;J)!@Oc8+i1SMbjkV z?}bM{-sr5jovGoRxImpFrusz3;((|D228*@BBR>XN`W4o8kON{S_}|88-w8Zb7X6GXC;eWmqBlmvsg_Ayn)e@9$r0~gC6G+d z{h8O9>-W#5XkkKS>@2dPRtHu9HvI6^i9Df{i8RqqX$t2nW9ft=*WPKfs`At8@rOTZ zxc}m>^;g$2l%MZNt;15GU+m&1xFF8WI#U3JrpJTke~Sm0O?;Fj(%_6Vxt;rUPTeD9e|%SvlAjRjs_oo7^_axv#MpDEC^xs7C6-IIi6-!h9!Cbm6m-Gg zp>Z>1Nw@JWK1Jil(PX&daybwz)3;*cwW1!f+SXkw2k-?xmzphy6C1CKKC+s+gBLd5 z{5LHf3Bd3Vd!mdPerj}n(@Yj``~uZ5*e z^F@&{cOO+TXfET7b#TkKyph0bI&RE`&kiIewZIe@{$;0LfHGtRpl_kZdl*`82m@>e zISnMCp8?>@C#fgTXG-NE%$IjCxo(Iu4MRNtj@r1CH#=fzf#=&`1|AqvZmJANWzYRd zgs%g$R`0tZ-++?aS8O$)~a))@eCSCd>u0wxXli&=50=w&+fUFo|PjgPhZrdaS`c zSK!VNW>n!W+e!uIfdi&udC04+mA0m&nW4u{WJ0d6>PN%)u{tZ^ZekQxGDUQvLq-2P zD(bC!my^-eRYAIgU{m_B-pti}UBO#l_g`mboh1Zq10Y`rJm)Siyh)oLAVkuDE@iF? zTR1N{@k+nnnZ+z8q1w};h_2t|Sh=D^>Zk7H7R$hdy8!MGe!RV5@E#a2B-w`4YBU!@ zqY$UjK~Iryh}i22rZt3W@#e@;Y@364tkwtpfRq>2dt!9#Dw~F^ulX z88R$hDq&<-Jcu##z{Pi#+4wl;C1!A1X`FA*q^skmMrZu2#}hN4AGH(Wd3E3ET+CxO<{Mp| zM~E7Oer6=GkGw|^x{*N zkoc8DxyGYI!SNk)rPDdx#?_}^rO7`1UKOLwen%~>#S|p5BASirjpD(tSFxu$+MA0{ zN`*?MdpUhzVs~OFVz?+D3FlaO_SK4&K3715R-36(ov({oky^@tA{Ge|X`0xfFCE^|kz-e_D{;eRpetfZ_lC^R zNCu$#A(XI#B1(Tx$x{jb)TE4GgnyGE|C=cQ|H}LcQ&5WGa_L#bFb$+$E2B6ZW7B!4 z(!K()Tenq6!ku?`YirR&3e#gG&-gSli~rs+;kDMh#A534Wa&N^4s@sk z$KGdzfF55M{$BgIqf>{1#O?7nqVMRCMjW3dIiXwQC9|F4bQ^sbZ1ATF z3XP625(q`IJ^3KZ`AtQZ9|Zi9zmx855-r_UForcyYLY?On+Wlz@2S625zKv&`FUVJ z*|CIU{~wuU`iBJ6h}sw`EiMoE{zCx*0{E`3nld${gPUgtIqp6!bqzXmBk0kJ|Meu- zOge2VA#_2j`1GnFlI(Mzi&%4M`PZk(mUepng7wb$Q&$Af)@6k6Jrw-MI3h9xJwX~X zwSUxj^SVjj9MAuHzr`W>Wb#s&(b#=T>Qi0*bSu&Jx0v|)u21%Yig+JNJpvEZRmKk> zq$IVRNDD>b*<0GqW&MCXktV6^`%IJ8h2hU**X72`m?ZfUR=Q|^3wVjp^BFRl+^D4Q zNnjKCj~M`XLZ4hX8VCB5iHXC3NU)SR(0cM~nd1>USj3U7Ex1jCCkCuH$+Q-1(LVT1 z%vzWIp5^7;ahYtv=yXVfE_0MNt$_QJ*Nv*lNBZb}%u{k3TL+G~&z zbru|JAPeU(;&_;*PQjEcA&GtP%hr_?ir1+4u%KI=Ab%pypK7t75`;%o$n_t1vn}Z~ zicAiSCw-9VLN$bu5^o4@N>-)}_)4kD+<_kzM0oABBK)C&jx7E#zh`J3JuBfqBWLMV7R)Z*k4XMl;UdJ+ zdF&dB^<)ZW?E>>zPZ!p==!Hi3FZlL3f=c%e6a1cYI=&Wy`x^7YBaP|)tuUzEzQSKF zs1h&yYwM(Tx!tRg5{85LdSc)FRXvi*(CR<|c&d|Cb=A7F=#JR%xARNI+h|cO1x>j2 zBSX11RO>F@_K;yCp63A_94D<+9Jwcnmg2iC!$-LHT&~57u!;p+iDecR=?-YT2aaS2iUReN&e}Yl`J7c z7j=8Kzj_d#i-=UDcBQXA^S6fAa`3y4v=n;LG`pf#wb{@#Mf~Y<#7>VLtIO_cqLR**oGyajPqzT@s|cF( zHUAc;59{6QZu9Fxexsz-vnI<#6k;T0)6QHV(0&lS?K&I$wMn4IWDIv4k zU~ErBJc$U2v)}3E`IW(M85zk>R<6*Qm4sL&Pt|&*jkuquxXVNI(~aKqwd0V(qo<18 z+KsB)h4Vu*7lj^RU#Vf1z_q>M?fIdJne?ckiSy1q$o9+vV1PXZ7IEMF&rY{bkI&sm z88huPcS3-`KyF}vzjZMLqPf_VpfIv6eEF*0-@nPf6KDyV2ZBSamV(yexxpuJk^WP# z$6l5%aRhpRmOZ_(@nZhCcW8G%al26Q)~dtR%fm=?Ye*{)Vm8U`5%n&x3ID16k-+-& zUZ;1MT`U5-D`nvAw}JM(+?=0SUt6yy9lRL%xbXW1Fn6iRd60NoFO@zsv@lP$deW`6 zploq5r6Hof2sHOzcb@gLoAv|yZo?i!95?r{tLl)Pfs12sMNg}rb2~8q0;{hXbbkI+ z@ml=Map!qTL5o)y?(AD;8JJsRXBd7x{RC`~f~88nNGmw=&<5HSH;)`P>eFYAUmT*= zu-m}A-%G-ei0$*e_0y>OsrAIQbL{-7;`?<=66<*MOshsY#N!(k>!8ROKMr>2E9;M| zI(ts4%KltnM6nBu{`e-fNkVwvqj>N04d7Sz@+~ye#D#Rs;y$h|+QT6}qA1A(($x3H zwz7s&W0p8;H}p>9@=r-6X5xswlP)fo-`v1vvHr@Sq~$De>m2chZ+nF8OBa@)Z}$V% z669PGkLC&<%^37eihfcS1ZU9y$Qp8=8pciylS~g&PY*Ls4|7is3r!D8POmHMg=xye z3v6z>WW4IBsSCWJJ8?2Te7CrE+3QAgdQ-_nMsvn_A#&piGGe~5zm?Sw2xzu0wekZk zOJQ31R&;_o-1%lH-BwnXU)qXa>YRlfR$&{&CV%pAN%3S?oIbwQlx_?*S?HbI;b-sm z{2-|F>AqQ7RgLbUFAFJFl6oBdW`}PvqbdCni|j&o>4G-EK`1y zo>tOIda3%PV0}JrsQvX|!I((AW#+1O&lm9l%g?h^Yj!piC0G$5%aNO&8nyOaRpO$R z#SYBEzTDGA$v?2i{k z*9vCS+3dy5D=hRqY^R2a59cXg@v^KwmUy5X+s0@0s8Xi5|E-xXkoq;knpQ#AGPznr zit^>lYYJm}zv!WL@s_fZ(}8u5Ub64EEt+e=UYw8;;VJbICKE(ISl_V<-eTinI(tE7kc8YO-MZCx^R1XH4A3mZi z|2PR|I=xN6XyoG0&ZLYTz5&(VnrO>2kS;b+E)Mk?Uz~jGq8B*hw3xrfy`HG^?6iU6 zsNr^n*ep~uAcL)Wt|MT$@8On7t$Q;v7y+r*)A@6|%tj#;8M)|CDf}q2kjkq*JoE8V z4z&|iq~H%1uc=8JmBWR-Y}xo_@PwD%^aF|ODe`}w{!DW) zDflw^ECIjWzMSTA;!x??PuG3S5~oiik`^13rIw$rleYZdjIHskAuBlTK$jr zHO`Yx%FSi@*@CokRkxN8z60U|a(}?h2HX(Aym|H zRzwtD)baJrJu|^#D9O{8YP*6Zs`rTO@(Sx#eR>m*%u|}U6*)$q{dmTa6853%R!Pg} zimfo^VVe~d3sUj8m4c?PD~YIW8)h3gP!6cDYn)?gnlGx$?C(47p14 zPpm?Dd%CduBTJDq8=E=rO9`G_g??=?!Eo0fZH(U z;W5_&Ol19A7wktOQ{pnekkaP+mkIQr;o>RE^v9aLqxY+B4Zf<0ega))(Rw{saA_$I z;+?ufztUy1rqn+Mj-wfF23DGA?af_3Z;~~4h()O0c7N4V3ZKp|0?Kn+(~zK99V50&Ri#mo`%!(wBvNvT7cl|uYJbdck$Wc^0i4(CQ_X9SxZ zyXlnXpj(%gZpQm{Y1xReYu~0*ntQEqsAZE5CbN~!GrL3@(kHLtj{&m4;9*%DS-$bE zY%FV-N67i8%#OFU8v|R!NzOaEFZ5oWXOXE6SKo*n+vk7W`r;a-wE$n8cmwvNKO7_p zjO2gxiRs*9o?XRWP*n8F{5YSrd9hsCr$VvB@Q-HPG=4*Pr~FKZlCobpM++cHmBl^S z5xAEfH8q%TuGx2GxBzX@42@W#?PQBVjklRU)xSa0z`5;tGH8i;Eo14>Adk~%(7Bkg zq2s%y116Yjq-6|;bC4;9Pr?67Gr%iNBkWRU22^jHRo$cWO zr;|i>y6V)wXlN?jlJ*i4Y2Ue8*0zmkU_<0-wS$|vDma&mwK6uO+rhukE!2i|SU}zf zWJ?OG+K|3ceQ`FVe{D*)NsG?OkrXZ}@*6E%Y2__NMb{^dkygZST+bzxSX@wIanZ86 zeSWD+n;cV6;~Wr;tX+lm@`|+N>80BDaHDk(GlGhhDKUCMp zu__c~+Y^7b585C0gi>R)GN@zN6Fwfp2M8Wo+kCQ3o^6h4=}$o4*_-?aw7iw-`FU<#Xj$l!SWsEw5~j-rG)>qq6&Q@#gSX4aKsR(e?-R7I6VqlU{H_ z=|Q1s4AOM4Pi`4>C-WjkWoj`lPja^hc%eY_~r2kyntL($pHGQfcdbY2FuW3@x!=Y>Xjjve~3u$VFCty!eSAo3=w~Z z#2Yf>_G)};kIre`jpRD?vweLesn&;@@on}wZmK9w@6Sq~8a%fLPH0xr0dR#D?u-`h zOfMY8bU|p3cG}n%i)U75zui>>nxIyypgz}2l4JJ~+C%yu`HKqKMSJ&^GC&)(MneHz za94*1_on3BeT=Oj`iKGkg{ zz(e8yJJ_yV`1kTs61va~mW?QMoHL};;*@1jqitFEf1+D7=7uT*V^{%8R{$bw$>Npl z+6D|lj{LYsES=DpXxU>~dN6>{hTel9l>0y=AJn(RRAN+Mv}mNJZEMn{s)#<@745Th z{VBjn^uri`DSJl_H>?JZ%%Iuu;%#|Kv^a+ zA*>xVe}j~=$vbQr6f>8}Yu$4-0yfM1W3QbQEmFlfsbZS!FHL)9wYNdNQl1=-vc?a{ zgX;Ap_nihPdr$#COW7;os!#O(YCRXa3rAUd&y3fxO+qrT3q9rAdHJ?}O)wf3BTFVq+9~9PpE7?BJk;vWlHX!8_hm z1~8oTgnx9YJo;PQymD)Ei-YoU!;7u-1b#Wgm=!3YPY1&tkm_H{b`NR->?d0&Htg%; zQu2sp{J%&-m!txCHmfgmdgW)fYkx6B)623@gJK2{U}Da{ciiyrz5yofJwx~@491f} ze=R!{#N9UhFvhRS1kmA>=1vEP7MvjkU=+xoJOd~VS2gUY3(f}qA!^iV|H;5lU<=&o zq1-c=G{va>K0d6Duw2W=r|UC6$9`so1`n(c^<6r8;YjJkSCGf9oP)s?Jii14&zf!m)rpq^c~op{laj#;WpS zZgsM*K$4Bu5zQQn(U_b*oN9o8PE__DLmU9INXBWd;t>QA-NeXLIH@@QFtjPMQgMOW z(h}LJxIpcpsW`batF%dzbw-vhRD(o;rU{+ibvA$*k#=dQIr$>F$g)dUepbBpf3qU2 zjNn`cDX*9j^t!A}ABLI-tvqpHgs?<@%?V2Rq3=Us)7)bC`jgxo<5Xw^_)BqolUf=!Tq=_*;= zHWjs9v@yzgz>^`Yry$vgg^#BVf2qX9QU|EbG&P(E6*WXC#TD_Fh^jys2p6*-PN!@tYVqre>0K_SAzOcj@wLQ#$+Qz{hz57e6j%f3(!9IUeEa zMnSiki!8yNhSJJ+9?2G;3B5TCLath*4d|TU<7t)xz{v6(!Q?iZoyZoHM3SdAb(7Zu z1_YKDM|7N=)bfh-97XZMs8Xu!(NiptpbPX1CkPap|nMD6f#0h?XV{0KKNm#Sq;nX!N>P% z4jf-F85|pg;AC*n8wk6~eVAF&?(h^5@@zWDO0-Ka&OS6wVnA}))H1xV$^#Y z%Xt}4zYG`LEzvwyEwr9ZM!2JsAjVb^SQ<%X%bcIc7SOX49i!vO&M!Mn(u9JOrujb& z>=eqOZq-gv?hFYNf2dpId}E_#0{fzHFcuQaUmFUR?_$SkqHXK9x-gOm06n6gz5MIH zk+4W`O9NE6jnClfyaVroe_MC^yHV_74EA9bw4{FOL$SN<1&SRbTjI9$j$}j%f4`!l3n`6&v>&V4>V^Zs z3w(&^6gM378d6FIoU#X;fQgB=ZQ;Tt#?_GqJ@uiWyW6`c=sDP`vvI;W_wILfq5r3do3> zj+Hu10kXz#e?pcTSJNP6W5HZXoCyN1rW|3D6c!yC-a{z((q5KrpkVWqgHzm>SW+OQ z5ZM%yB`g-qJAq6)0;G!oEtG>6jfxC11+;+xBfN4upxp;pcBxBx0l;!#G*DnriE?JS z=~rScXq<)z5X3aM7kn%5H@X(yQf4KIZIqm-=$Hg)e+qjcy4}rtA-ewNST7Na3HuxE zrP(HUGEYVDgjlU#zxtyDi!{d`s^@GtG+y$WbtSDEvMNSmuYIngaee04Z7{XK|gpr-@$ zbf9}8f1hf`d-@v?O}PR#L{ki4vSP|CWq3-dB6~?N%>*byOENEIi*u&J;%rpljj|ND zh!hvKir5a0e$g$I^VA0ey^@2qEXuWi7x5IEcN=T0nXr1G$HUnyl_1@#pBU=`>Ebmu zzq3m}0F$Y=hVV`p7RO|2>ensm$o}``Q$wB2f2p&%?u-LsFj;}g)ZGD-Y0d_y$L^=} zYH*kI2Cza%t)`WU$!w3-I?&Y1&{*jQAsGCAB!~jHV^SV~#%zzvYK?%6@jzf1*&{pj zb9j9usn&;@#~n0gQ>D412J{zR^22REJh@U-_RU$mB+xL|9$26Qj2T+8GreTwVt@vq ze>ttauyL4Xm)%v*1B-E?W_qp{qaTOav{9==7%Tub;}Tgymf==>gGp*BX=E?9z+qA% z+JnQC#WoI;7dtpisO4ce%s}(zMXtUCs30&&{!!Db9^%+wg~dbLD4l`QnW9usBA-Nh)w6b9o}|huzi(lClGQlw+bU`hbta zt3p@tMMk$8IcI5uqrg;;RnsHAuKfT;+2)F|U#{{0@2(htjIc2J4sAb(QIdFve`e5Q zoCArL6pdaGqiRk)tL7Mvk}MnasJIZ1AgVh3FvY-%DMqXtPV9&^w-wwrr|_E5DcpTV z&|f_B7teVy0Y+HN0V9ncU^_LvPlS3eHY*J}0JbQG;v5tj9oh$5Z0165p~M`v*r84R z<5ejcOBbB^M+YV8yXC!dYYW&Se~ZT}tzgXr#|eHxABNuSR$g$JrQU30qT6u>JIWS~ z-R7mzQuth)fUHgk6uU^i^W5&*w37j8(7~@xYmMSRgamD!=p80Sm zJ-~l5>_-gT=XnPxG-jdKmk!PFfM%%Aa0Q(fX*u9-b3Rvz-cgKq{0f#;PdQ=B;cD6` z!Vvu>(O>Enq%$IshSS}q-wSjMb?}Kg_@q1FH;VZLS{lW}k>e-3IPwNv8N+mLd_3=c%3>QuDT{3sB`@|psjV~&M-nq}S2tiWk+SW3 zQ`-p_QxMiLn0=s2cbJ@jPIUF2IsEbJ6U8SbfBl5`gcu3?BBre?7av04>|GJyPwicv zirOyRj`sC0%T(dTM#-Kpansc`L5EyVN&=EcrpJ>+SY8luS1CI8|@c&e_MNL#Vx1I ze@O%7SZMj4O9}6*1)a3_)B~M#>5{DhB^e)cpp(3T3!M~nCQC{L$mDnlI3wQu#0OU> zB5V7sN3z9d)}+%jyi$UXyU?dhVthElI?W&J7R@tcNr6Xm8NOu_Rrt_EX)(@;Y(b}B z7&{775TvK$?C4)*L=O;&f0NgZN^$^2B+hWzECUBO$;+}R$8k_mBJWQ`;tWdmO}PLi zIBz&|DoQPMCGVrTDc6^ILHvYk6_a%=fwUr)2-pM!l0KB7+0jN zlF$)ryoTU&r)?(K>RmaklNTAu@H(7cLkf?9P4Mcvaq#YaE!HK?w^x5zrw=FD-QLAX z2I{Me|9!8;isqAL*1YB1?WP^-77gmLTf<;8C3g(iRDqM^ErK{n`j+T$oFrXl;W){m z`py3Zf>Yirf7y-3r3^o?bS8Rr^aqs-32ofTFcpMM_}Ci+B?DZYm0FZLP&aMqXpmLe zxbI7>Ov14Wn7&R*YD4 zjM&hMe4K_+59+wqQgUJfq}#ugbj^oulCbto68q-2f2igfn+!m0HTXE9Kp?CQU(2>e z>VDhQrA``&=<&7eMNazLSJJVkv}(Y=Xs=rnI~lNU5>wi@ZvIfiBExgS_?$A|bbPAC z;K9~Ya((Z7f`rE#A%X)hF}MT-Q#NC3!6wD94UP8YqDn1Z9kH`29E(ULvpTuK)JlHM2Lc&5c*l*}h-ap@bTOZ%Ne7k>o-FaBw z@lQa*{Jw~9L?h;ok2r6h>BGyf;uU~$>|1Uni4NbCnxyOg5`DeaADC|COUfy1A?%#HIzN7rV8~pI_@fi#a zA;-7O-|lbqe}m+{{#5zo|C2F&6%9j~V+6nk008A1000@2PJ|W$F*1{CeK-M5lcRm; ze}nq_F-^bI0e3$$#~`902??p?MgV_a$dV+<%zVHY*6cqfm3{}2sFKrpdqYzC1uMKrHM@6g(&8pXsYZ;-^Ci=p}f8I%B$jUy&k&RRCp1Y??4lKqmZe z9Ak*42{G3 zNjo*nNontZ7?df%GcWVWEqVcCLov2!j$O!O%jVdnJa%s}X%?2@wSa9I-UwKk+~F`* zs9gao)LRbQ3hXttypreLHOH*6Jm^btAlaYU8 zf8&3m^*=|IU9nVYrCDhf?7izQw6k(lomEApSs{b>p7ov*&rF*pX||!)m%7crp=dO} z$LJnHCZY*=Ji1gqN-#N$hh^+TkdwX13!!s4b?Kxrt8r_L*0n@i`6$T-_&|%ML@ot% z2YuuK_q2BGxE&rwUOg*T>V?mVb{Oqyf1;X3^7YjKU$3v26E{$T`gw3e8CsS(T#SQ} z(|avk#?x90fZ0MoMRGB6doP5?RoK;*s6O0jRrfickCER;b;;ATQSG~z*4NC_POaYu zk+l&FPQi7%%CDpA#Rg+S8w};KaR)5$WY&D3Y!nQg@fwx*jfwy`@ zQ3G2|qQF~SqNryzF8gLsMYFWUYaw8@r_;kLfIsT$1ZT@v+KRei)X^NH{x#*S+DJ_} zt`IgJU3{(uS|dv?Qp(bA&yE>&f8=+1Ch47a7C=qIx#dqSykfF{-lYkFxS<}e(p>`^ zF`(AsivCL7fqI55gJEqN&ctfP@ABD@24n#TPE96V3b^AqV-2ahcR;OO7PUsn8*E6y zxwj~_)JFlLv1`L%=%lO(y0^fAA}=b(BZrf*yhFra@F}<{if530GE#1MwQq-nmscq|aGh=biEEt-3;SR|FM&&Z9&ZdD~ zJ@vopfc)OsG*D61pxQJ@gG$rjNrUQTjx^Z1&5=jDu5*T@*gLFEu?qpWZge=c0zUxt z2i4zW0;9S0*+TeJvk0qgqH?>XSH!QxHAN|B&W;jj22v;aa%GN4=b1Pj>R*VY|lX_XgWNP<0yATH}-rL@;| zv64M9&n)GbrdK)9U?XQwW#Y|z&i-C2{ro$yDAEO;VbkUzzz!bnKO zUOpg`H+s zF?}sgt`*kqr!@V-9?Um=)c}NoCNyG&D&v9BBxE&)()5Kpgb^eHFk zW3D`f1s$cyU-72gff7In8@df&l5&;4{z2pCT?tkjTEIHtZ@!Ib5dj5|iiVnhyvJb~ z2E9CeRe((diDV(uhUp`~>x>L~5%ZmaGhh`^)-faFFiLe@N-)X0H#;n_5{pafO%Cvs#>04GE)?5d9F2=-0hC@uJ4K)`* z1AIMzHt>iWv+Z)rU3kBCVNN%Hs*unv_HQj{QOxBr#Mi?bz_i)`cijMY*uSd)Of?wc z>ro9LmAj}4`?S28LkzA^azU z+vz`uF!N^gu)ex)RtF&>f;|rr6JwKL+m?7sO|JD9jR{BVm+G(9JYb9Xh)+}2Z@=VJ> zHbN#`xiYJB9(5+qIq~O}x{w+S$n~IZ;F-S90EDJtm>mOI%ALL@n@Gn%mTh-p3*s-T z#DLi~6E*SgNL}vxFcO-77Cl*z-=T$^e<`DT;jkp2XnpoB5`vKBI3{wiO_1dxPZD)^ zau39RsFDMRO7cx^uI6|)@j&nhTf{ZURxxM=COjQ-_ai~+!8%Y{?f0& z!0H^@oz_vOb=+y42&*&>rot+TWX7zO=9`&~G=y!#c09)+p69rKo-~m_*er+*?V50T zW^<48nQb*A7aZ8kuH&U-VKBoAr}6Bau!PPf&Oyx`zF7F$ZP_hF<_oKlv-CZ>7Y<8{ z&**nKy9P+uz>e+O7I7q0kZeZ=q!NS!?5QRcp-S=i=W zu31}9|9P?+%qCZV1MCkP*}#`U`bnx7^58R73~hhJasYP^4TrPw_gk_(XrBiw?W4?y zEB&PLKI8!Bj5z*?j>TdH*tI(Z@jkTu!>p(=)T^ zsyGjboq85N(`A@H$A>~m=$7y1q0C%t_YDoM%QRzqdwy>GZY+5(maMU13#_x)hx}+Jd8_K*@69g3J;QT#&@sm zNLt2GbI*Urwl`0S3Y*|P%x)+cF3^+KjSv$$TWlI)=Q3Vhy$##;j-=2$vG#c6D#f92OJ=14S zUo`!9-}gK1iDY?_9tOH)n7T#|ak@?p4+H)4r`e^iYk3hJ*3m9Kkb(Y#zCsS1;eTuu`Wu$$Rcq9Lm+Q^gnSIQ(`zR-qboWoPF1D~JXk$$_(c`YT zO`oqx@_(=`!0G}kl$>z=}rWxM`hmD{5M&)Vdjt@K^Z9M&WG602*vK-$of(>-;EYIGjUN zdBRv7pI#4|{^zaN`71#1)6i~WulZi?{=WTmaew!Dc`=1G@E?DOePP41E!Xj|?|L2% zZ0i(X516ayv(Kk*Y%}^Ci70M0C8DSmi1NN7?N4pwmuz`W*o?vIbk*WT(n|A}z|#8H zEi4o3wH;oIbFlQ`i8?!++ZA=LVf&_Mn{MFSrsuoniTDO}GzZRAo}*Nr(mGLEr_{P> z34d$qgj0_T3+cm=)2YkW>ouaKgqZ&V_F9RxXsSY@86HNaV*;Cw>-(N}%BBX9^hC}j z(q%+SG8%KMl&lkOl@fbOtqme66RfyEib?r6Q-WDdZRH~*xWci(N`66v3ap^bGkj1V zC=dQxmTy_7^J&mV&;4B5Jf4nUrnjT{^nU_6!^o{Fg;Wk1v?a8$7fyuGpze%>qcIN0 zl_O+$a&2h&qFm!r9Vc`nE;=8a8<)@G`uF>8b1=S)ZjF!4*r4t-N~P zWuxv)iqG;}5w<*XFGByd64nS2p<0X<)ZiD}7NBW5N%9^Gvy{CPVU}gj%utaLs()&P z)KF#|(r#V|g)>C^ED!|w4hwgcnR$l`u!r-~1!x~OS-Fr?Lu~X^oY}kRoX*C&{GyEX z4MJ~6Km+U35_vZr8wGp#ft?P-3hEtGC*#tI#3=_h%5IBx!V}BDtWeDuRI+54ZSA8maO8tif=<-w;7=FPnn802J4Junub(_AD~s6`dc+Yv0oq#}(HHyz8tt8j=S zErL=ir4wl#3RFlX-~mc2E<08Pd$?qyH;5Bv=OG>Y#5PKaNb9aTT!Ec^9DlH!wqO=2 zwT4ex^DGx*&$ny`(;3q5XhWzzLcXT81)x=P4A_B8>WPL%M;VsA5RE!}m7^fM$Lnr0 z^Qd1{w-sn9sh1sS(a5E&UUi^FE5}CQqrkH;wgVU2CdSjtjv z(!rF{NE~R-{b20e`598PTDonn@kMfR^ew6{-p?c$9~G`WdN$3nG2P0~&qb z!mfi{+d}U2vg3;e)#swui4>F38}HOBBt_hSN0ny54rGg=2o|Ev0-u_Nq!fx&1!ya4 z+_Ga$u!l?dsOJX^l<^Y4Hd3_{Y5%K^l?AndfgA@T%XjR+H?eO5wSQe2t&e7}Q_F|5 z(Hr;(6athqa)ZccZmlUd^RKn&G zfdj=6q=_*M?M^p)!7mJb3j{4i@xe!_SyTc5NddiYM`fLCDYwf>0Q}PJ&@ut>apiVY zTZ&ZC>vQEwRbttJ7Ju|gUv8@ov|tx*eQehZJkNGq$8`gz<5Qdwa(3|qv??Akw;^eu zzG=hRxB;gSeyC1@4*-zCEsoy(NJRY@UbR^kb@)NE>L4|3Sz#SjEa2@E!G%KC1B2hQX{K&IW@Un;4)uz<6fPuisDCs!B;+-Cjo+ z8+B$%N~KbnsjsTv|NYO$hn?@sm)HB%(}&%7813#XpKe!Q?w`JX*!|^lJScW|Uf*t> zzT7;lo|YeW|60E8{(bcCfB*LWkJZa>uiuu-w;f1$di}8b?d|Qk+TVY@{kD9(c^$5v zmrwZQZuRnb^M+qvzV5$1zbtRQNT$b!eHKO8{^QO4)2@DQ;# z%gwJ3nD?JCzqvKC~ayAQi{ zT-9f3vb#TeFEw;^zx?C1_5U5A@LyM}-^2&gFCTUz$aq~oEN{iscW&^{_vPX8;Q^u; z!=n9DiDj&suw01Uf46em|2KV%Ti$!<;t!7i~D94X3I> zs#11)rWy)6j&s_u@JuG@PUeDkb4eS1p$%8G;S+7RrVal?8$Q#9x^`L)oR&kU<)hPb z%( zUv|~T94FNnf9C#rFSp!5!(I}z^s^r))v;!ecSnZ}JMXej)bK9;dvUpU@yp5H5%`jy ze$qothB=S3G*5~w&y$kJWXcQZ5*ubIr?~f@i=**>4CK$B>}=()#Q1)Q>+*-VuGFGL z-4T3h%esO}MahCBYEAlulS-}fC!u|GU;@fN{E;rMF zbbg?k(R16~9;#Nda7Uu`&e<$SygJg>&UQyN5AHRGUF|Qp^zS1^MsVyUj)mX-J|g3q z_{TNjf7L{f3kq&F8Ly7H-DK%7D$6J?(>O^>mKU6iV*wriz$W`4uFD_dx@vPRU@4*P z^vS!Z*KPJsYd4ux^JuT;g9F}dvLqwhXQt^6_~5WbM_0I>H}cwaba$L6vU+N!*1Mlh zy%Vj^w4hTn$#fW(S)5|8u{_GMq&Yk~y9{y3f5xFqoqCTfZ|kAA^+>dKHksHZGRi_& zL{2X+ZKO5{p*{A}>J3F`Ctg|^r(z7lJYi896;YmMMUm&^%w4EBZrfw&hqx|(i0i7& zb-8ZGvRX_e)MfJk?4J>rl0lC|$?brK8Y-OfchF#>*sTNC`=ICxXuz?5UDAhrg0xVXv4o%^;FZ&5@KvfdfA+ zvIM=RWW48w0qv%XC@PSxCXA;^e^F*xAbSyIrY&kjqW0w`ALBTxCQ=esITz{2yV}He zj+ubYv&^zc@qI*1Vl6Q_!ly2=ti++cn#Lkc!|1Saq|vAm8?&KS6Oc3m*DMxw7D$51 zAsI%sKQVKShCF3u92Iebl0lIaG%TM71f#v08^MA`TV5QQ5k|up3(8m#fAg4go~JZ{ zJyD`ZryE<@spN31^-K%Gn5;4N^nGqw%noD2yo``N=VF(XX_4@wK@&4{4i-7>&8w8C z<#;VHh6U=C!M~$AeOKcolbeBTmSgd`8{MN-CBdXTw4Ry-LQ_ArELFM%Rbfk>k(4^Y zM#v&|eTLK+>mHW{iN%D)fA}V%L#b$(WGqh$m`jPw3i&nRKT-Unv&LlByO~qNu(@fR zNfyV*&b1^=p>c7+(RS@c)Yvz*my;OP5ELKJTe~9Y7-d|2YB=m1*W0qLNb7DknvP^S zm;JOA)1BouHQI4(O013FrJ1K9agXOX!Nw7t!KH~Ii4)rRGh*C=f6ixbIxi;HHT6^L ztw8D(Gd%+^$&Y2X8vn8(27<-ImJE7vq=(uRwIws#{O-uFunWJ!F8vC-(xcd0Ft#(; zS^SMG>4U3EHb`s}qF1dl(_Qx@fw>e_LHe z!vf(3OL>%_f0oY^T%dGgs%y6=xn?%-Nn%{q~;(a@%K61Gh!b^vPO1nFI#Zl;%cvRQb$>>q6B=bf6F1U@FKHCB|gf(19{ zzqt#Lf9p7ah8QljJgFuO!J%DUY@C*>!!0>$uF10@$5jL_OUr_z$eKlD$1e2zX*J-| zua_&W7dW+~$EoE}9!FV@{HVxM2oxG0T~6=pGK zPV@ywqSArS)|#llIP$B#)>byEkC?5}4fBX2jYQBFi&MiXH&0t@1verp&Ocw+p37m@ z{X_LOGwfi6;}BDAv2(&seb_u;xivmOq1NgW@u;vR-GLv5Qp267C~|6t-|JUS1DZTD zf3i-kCfN{f7zuq*=BSHgaSLA6$w=5%hyqZ1gD!9Lp`RM7?L8D>Ce@MEA!6g2g@FaG z3>}9_2SwA-0JSNUkQ$7i8ZKSQ?z;^2&-%jOeCcn#QezNi#Q(o>mOuY%TvBiN)F+@f ze)6yPXU40~cD<3E!2fUrSSMBYUFu*;_i~9IzPbSkWHMIv~AqR@uDd3>JI+Xniuoa3g zwHAl0xM%J75F4W`p!gE`d#&e^Is);gziq(yUCcnX@lMKq3-DGm&;8ZtGT7DxiVu6E@F6 zi%31uhm9yJ_Z5!(>PB3HaUzURCD^15_{C=^6~WcnarUNGh%LMd*PeAvI;8>*F%aK^ zY5tANKieRm#=>ohiwMTvp{QdXBIp{%u_AJ>B3OY(4+J1XEC-@8f9$SzC<>T#m4YJz zVkQtXv0`wxpoabK(2AiKMta2ZB0_Mo!d^rW4>8lEQ&#Lx7{lKNpOSNitbilAO^XPZ z5@d(YHLJdgX!<}^I!mGgaGE^FPnKn5mM4|8uN}Xax{jr!DJ!d~H6?Rhg~kc9 zpeV;k{Gw*ynpsiUnUF0k2!C6!ER?i>RpQ7kOJE;3$t~xu3S^xU?bY1M#tt-Q)<$me z1Q)^?GRFdNlrp1O2)zWSo7>Z=WO4B`S`r4;Smyf9&kak`e{3iO*=3BnWSrtAB`uRC z)#(HUa@HH8XTo}7vE`&x)g5hrqp+U^D1%w9F;z&Dh z?~EP{jb&*je;KxCg`hDk8_h-`Xe3JzL4$Z^3uGgxn{(UNzR9_*h}?5K!KE>x9R*H? zMXGZ<;KwHcDQL&BZKQ}t7Ui*R5p~_MOaoHT4v%f5h)7XDWTj|(6-===dhTG=$9m(C z`_MOkIBBh%>oJ(sTx~>aBv5#b>c-h$6Dz?6vjGXyfCSO5#$aNYB*SLQY@|!V z)tR0!fB5v4Xe~_-=ti@erLlb=(%lSnlWY?@9)Ma@LMggNH&b+tY({#*aY-reo4Iu_ zBz_z#N*834AXI?4D{TspO;QFyHUSyOka28f2#`%n1_jyZ5w{-C26Ixj(#RMvs2I=o zurkBd8nLN`Rs`9Y7k;%}`qg%&2eAifvNXyQe~Yosc7WlvF*V)$D6&`TIxt81fwYrUqG=%ax-A!HL?4=_ zJto47VoeJogq)LHntaqt>7Z%M7Wl|b+~lBX8WMv}j)CltB7lnU?v$7#sHC@E)0T-0 ze_&nfo`3fzNO&+_KPQt)91YY3b6kU?Y4^C6@+6>&Q!~#KtBQUcO~Ye!BOnO?+{6V+ z^?29>m{7YE-3R5jdDP^9i^$%^(dcH1qmj)U`87r9L6Zkf;NAE7}P!xiof~L-;6c&7AMeNe;sih zFXKH;2wvjw+bz6L#Bja4X{O-zD38nl2*pp0?YtQX#Xsu{fAgik`6{3zv{zTw!AP(Z zkGG6e0?ODNmC`Gq50w&_+-FR#uI=oQ1MFeGgHJqeBXjYnBXCtIGA6*(a7GiC0;BOI zZmFq<_QxWD(bWfHcn5ZP5;cS2e_gkSmkfa`WK2{bg%Y9+kHb0eU)8|~vKs7NPt>9J z3?M5lo*sud)~4k^Rzee;iV4o_1SMnz6NKfid7DB&-KH={F~Om}=c4bq?HjoQ{C5mD zx~A_FqsX~c%9;>GzkR{*%$h@~7trD;vK#JfQ-2cX?E|#vW(sK0%@oigf14dZi+Z=+ z_mT4+20yuRmK4wupbh|90z=sp(BfCegFqHRIK;vMX3b(({*(=%o04!0E`MUXvT4W>|*Ms0TDr%%6fV_MX||!t7Q)3 z08B*&1{*)21nLe<1z9+Df1arV5sN=i)GkbgC)J@1NLsKDltL;T1Z!X_u0;9L2M_W? zx+O%6o$;dlP%WAc$o5Bc>J6aKUR|2;W{55=OaG{$>(KDywkOg0}#f0*n(Tdcln_6fa6eiKNxIEb!7Fms&kg&9iE1 zZ3+2_G85eJaC`egFL(l?W)L;AqL6M(Ic|Wsc+HEMuy}b83Y~cLf#C^ID44#javqS4 z_G)frBW^Huf7ZSt0(uISZ9F&|i3f$Kg`VgoINjW!P9=+rQqhtysKzwccYbbI(gtwA z5G+Ol502Li;aT4}^p4c69_ELRyeJi;yIjODJcbb(=SAPJ;7X8Zxi&(QO$j&Ti9C%F zQiMu?+LV|mLM1?M5hi^Il>mQpt<&?47sWq-ooZ7~x5gVVVuH1`wNSRnE2vpUfZKM#>p9Z9$y_#An zB1#kxe-$B`TfCm*uGQSZst@(X8yB46oxwn#0)YxQlu_iVR-19QEl6PaTbMeA;@If7yno1`1c^4q_9<>s+}<@%|k7SoS5} zUS}g(Gf@gs5myi%4CTa1u)%CV!ZaX3w5$DTLYNef-=`MaBLdmB5zUkwtc`eQl8AJh zwJG4riWF#9p5RqI^u=Fu&1sgV{nDhKz)^jdh5D9>$K}gc`OO!vJGZOf#Wzui5{_-v ze{b=RD|~?i%$l?>P}s#66ySsXM$YK{^Uc@g$<52x`={5Phvl98b_)a#FY4vZ1+c$j4$r4{>0bs%I&fRMDW`02@Lhi-#?f2)M=bPu{%fy9^IX9X#dv=A3S_~mft@hzN+Qz{?`63#%;fe zW%PfOp$ruY+)f{wmjwU-ITMq>3>kkpE_iKhoLJj#+c*$?Uts@1&{Ovz7B8YMhV7!Y zVB~^aw(0IZD>5Amku9yHBu&4*LyD4Rnp)diAgDFs9LFS8SF1GPQJ%bR z__l69N}k0v#9yt`qH57L$tiG~xO{mnE|Ppx0K`+8rS*pdwXIDuzIxu~W&D&u-aoJ# zCoQ&oIDp@zNtsvqsvZHH(*%Edm~-fa4j|1Y%M>yY({7b~HMPHx@dNQ}XEu=&^moeN ztKM%*%=c5CzlaxC%c+e3qT(4(MCMjqeFa!l-_!8Y-67}-NOyNgEz+HWlypls7Z52) z0ZHj*3F$^u8l)CbIu{m@4grC0_5I%W_y7OS^W1Z1&diw;_uPAT=iHgWzwbI08|RlP zth2rs&i9hEL!Cy*-1ICEac`ehDti=28gF3sP!Cjm3S7n z=kin86@H@@sgstDVpTc9GpMaCG1~;QYe(Tu4rXJN=)UD6`>t)FOFC2R37@$J^lc|6PWwQ5+lai%Wqz{$D z=yFH}G@F31STNL6Iuz~VIQT7^p3^G}Lh&3DLN+BHJd%D_r5A=Ho0cHzeXU#lh+>7v zirpuH=oly$I12dUWv^s%mCYX~oZvmn-jvPs_D_P}KOq_>BJYdA4)0m6IhLiA9Dm*R z*;S?q(GCa>_}U1YR~>Q=Y6Shh|Js9)T>SzM-gh|ba(O{0ig|JD(h)vE$67-w_;p4; zC-TDt^zqJlmp?Bh*8_aa7#qej)J=v5&7?bLckcsvJ4O=J+ovb&MitNv!U8OnMsd}z zaf5S=pT*>&Maxcxl6J|h)Jo#-3K5{jYORKg+gAY}wL%~|c!HTS`;JfKwVkw-8V{H*ow`9e3Km%G@hS2C+#?U`PA z&D{dOv_`1HfA)3K9o;TnB+Vdn!mDlbXUixXt7c0yi*GOV=05Cw+p->BEawzD!AT3} zjLH-=vbSz8OnSKJtM-tb48gry*4vd*Z|R}rtIbGoz}12oQ3cpbeq;3Re023nSVwUJ zzNs`XGXK{9QqDK5TZv!A>+1yfMf1(8^u`_l=Xzkss(>e2{D=1&pR!2f!1t)kgWX+Ya=i|v2l`eUYmQkrfNG>1JYOvIN;hjjdXUAZK)(sg*lqaI&w>JI|A`3v zW(DJ3ekd^8D@|Q~A#6AojO)YN{bth#uUT2SaOtkgp<`y4Jff3vd+{(gP`Q0^PX7p} zU!|I#ToD~3zm-zQMWB(*U`+@YYNb-A!ZA33!f6aof57I(I)|AX=lV$$NBD@*hRuz? z(X*z2%B1^s){jAn)Ca0Aj&R`jjI;ZfUlI$bxg`7pLZZwWR;_4}V@eRk;#G$FD_(sf zVz4}h5UZU#xbN4(-Y3|_T)0`Ls1t%PJ`X|VJ4_iwta!ORJo&xZ1;!kVpC{d4yBD<` z0@JE=H3Vzr;%c;^z#E6=-aT^hMuZR4r-H-dF;doJiWY49pe8qc=}M$uf3DRQdKMkR zh=d!_NPd-jQSBFZGWuTj;cf|#^2n`^cSgI}*B@o2C8OC=6S zQ;TMi$z5+ad|&-!<#Y?O}U4U8+LV#eA_8xq)#k_lNKN;NGloq$m;UBnm@Kvz{=vst!L9d z0n6SdmJMngogWET5YpXZC>$6;Jfm*;fp~?@_K}z&&ku@(kSYIJb7^%r4baK#6C=1%U zDeM(vp#IuLFZWQVdTuekeOV>JepDw41$rHL_fZ}_-){8LCh6FW^43gc;8$M5Fs&1c znlGr9W^C}UI+`{5p|_(H^m4Ry@&#S+xWVc#jLjd>Z6!O=68U;5xXdUAddD^BDMZf$ z9c>6`6?ovPT?1$DLV+JRUy8Oni^ZG$DK=nm{oeAi9*rVShm9y8SKaL~&sO+)1mGdd zAKsRKgQF6rn#ZNw;Ttj!jQKi@;EwjP1ngxCYkHZx>=W?j`UHSe_rT!NJL)ru6|Bu_ zb2~#ph4*3^T%{~yr;t-h+IAwA%;217hYa_vn0##C%vDdY{s}Bi4#EUs{|zkN1EX2`;0po~BTE23XC5m{XDfMoO9$6KzlxkcJWqUN`0mXLR>nOY?56R>+oglBt!MB0 znA%cax&)C~t1pC7%9B1^x(^Xeai?P07-5ku)A$8glh}ZEU7TI;i9NruP1d zwx<)gJih&P=?esfc+VbPEo4`%^Z@s#J?1@k7k8ILdCS2!Bk9u8K~L|ukbVqr&kk;` zdd%;SuNU&nr8{qaE*#Q64Z1%&J|82J{(W{m{k(Uk7Af=md~61O@!}V)9fNC)S+L~2 z=eaS^dIeTtBTT6+*?cNyhSy7!?%7 z21&+pjwr<#^$~E4B+5b35}wdT8Q6A%w;(rZTjJBa=<9|jb&A0Nr`W@?82cRNLU%_U z)?oBvl={vDo8M6*!`*a^ooxrqC{{~f`{@cQm^UJPvN~SyGIvEZTXR)(Gdaoc@SBug zkD&haDUdUn{m9h#M3AMCxzXxPbA)ijY=n<<0apP*flvWL{S3!#VCRmo*IakrdmP?c z#&Up#yj#Vmr3w&$P+TiZ@eEyjPh#emO0>y9XWzKbjq(HA>+7#-o9nv3e+Vk{EKBn>D+cf9LSI%;`JI!Y;Us zaWlen?r^b+A~Q??t3DLYl!P#CK@q4$%|vqu;|v8j!}dd+58KtP-gkHGl}15?(Q?Ff zW>?h;>@ckfk<$mNN3VZe*B0RYcCw4+D5!c4tizRrk;IfVCWDw6pEem4cGqhNp&H=N z2G&6Pt-0M-=hBu4xUYR=ElH{S6JFE@9&M@;HwUlLYOMssH^ey+6p zGG%#s(*7-TWN*Ic{hT*BrNTT;8iysZ5Va2dbd@pSK@Rs)Ki#3$LyiZ`_t zk*Sq7^0+?oM=M|@JZrvCy;`2ta}026C3IQB#ktuQ5GY+FkbS;{|POREv-?=6(@h+6>TRQNr^J_S2*I+<`faKx*NX|y<= zsno=vVK5Y3C2CF`JJqTqkZha|Pf+6WBe#R;3B+c@A^odyy$G(M)*}vET%Ns=(=F5;~c}wdQ)NeYRaPgLb!%on?8}E zY-|Bw^0!@j7D}VNU^fdOQ5yf!#AotaE@>8O2}OS)PGL{@C&lhbdiF>0;8 zb!6Ayh#yJ=p|D_!258`b?eoO9>X5;p98W8>F+6)S8BfT3kZUMB`nMQX)^sh-(9E2#%-}qIZ3NUBkI$I6jU6CdN&(R##-?NA@(5c)iCmdvu{`kt3 z;n{xLl}4E0QIa$LfmBUXWc#_c=?Ha^lZmbl^&{TOsXp(ycNLJRGswJX@gvf(HVFB= zSH*#hQx?PL?HtEr@*IB%y{YE;(eJDPcDrYUf&+^dGnL-Dt-r|bwTVIl0{ivsYybGnIQmoVpT!=s4gp`J()VYz* z@qMefh+pR(6rJgIaHf1$NFkDpvHx~4wm8mmh3X=HBX**sl7pU!gKc=zqZpUVas^kZ z@t0|{-*yZ-OeY4yL8WE0*;O22hhNTLnVh~j1F(`b$!d;)6y)7ry!W5nnerAyaIeJHklWY>Oi~R~ zwS1IqHa3i%(x|pSGqcy$C^vj}P<+W=2-TjGUzwnw&?c?evs8Fq8_QY-JBP8Uvi#g+ z1qxuL#4U=1TUwz3?GQdv{UJlNroR5K((P|-1;LA`wr;EaLE{_ z@}ZbELabFWO$+C+0JhXsp`V?*7kbt-x~;0-BgLxvkdG0Y(3h4f)&$mQ)_B%L));sc znZxzuCn}JzddS5@LoCLaOO4P{Xahz)faQ^BkN_U!bX-)Qp3P$?R*sn^TsjiSzX%f@ zHnK8E9;6kT(|?>y?WlpUCDJtxQ_2=fHg+zaWZqzMeF}8O9i|UzxEDWKN$|4zmi#RP zqA?K^4%gjWYt@^9N-S>*cC=Co?eK#79@{6*oLAAn2>NLB_NMkLoW@Bn-OrtX_6v8r zrPui(isur$^V)OV+%02a?mJ%S-0|{d?(20sI!m+5OEh!xX6a9`36};Q>uc8S9ZK2f zLw5dhe-9{?n|pGxu{_auCv%QfIY&`rvO>^gCUJki^_~IhDe^2T?Ie#NfzA{t^9XQ8pzQUy@%St0E(0KdN0K z`cjivU?77*k5Bo*<^&Cy&fxT3bl9TcM+aX6YsPcBjCl*cJa5YgwTVe{i!XR;eqk6q z8D?f$cX)4UJ#*MTuitHg9+T-bma;^<3&MXHZkDk`E8CB@L9`jkIsrQg4yJjdVR9eY z3r?H83!^&K%qgjJDt3YSk~0f3JsKaPaPGdj_!6p&Y!!g*cuL*IleK-)sy90D0=#8) zfj+t6ZMEuMOd@bmORbtypg6##$WGg5n!w-(*n2o6 z)+8UlL2i*FE;VqP4_N0^HYLALiSxU)rEgN$*!mCyJO8N{<_EH&_ihtI`K0rj5Vcmw zy}yp;HKx;Qliyy3+;J;USo&^LYXaXhZyiPmbpWrOwW<5`Oq5?b(Wf{3_e=-m~6~m%40gMLKuV}zF?j>-pizkbR zr-JUGFv_=BiKLR{V7iiGic8H0OG*)Tbh%%eGuSD{`NzKV{gndr1w0l}N?kX@7HFx@ z8~Z${)ZC6H2Kpg)N;pV^t@%K5ZGTOlMz`6h#m{ejGLD6Ai>y^-m-FL5y+5cv@saQ} z^48eo{RC79OmQFhL%l=6p*yo9KV`dk(`iF@n1|0{Hm1J1!YLL^+5xS5z0qG{y+HNV z+qb3|7Zjp;p;#r#opq{vslVaa=P)tvxWEFwgE#%6R0(`QqC2PFf%*IwDJcK#I{`Ta zL+aB%S&ifum}KALsLKWUY0WZed+t15>uW>cbDnZR*V&YSSOCI-i^`4Elt=|j@sM>1 zK2K(Ql(8%va9<(8+a+=)Tn+9L@sjc`D!L4=Df2k%9(U3XJjCDYSzdgO$jD|no*EYW z{>}2I&LXU2H^hb1Z5S%OG5RzdPV#MkSe{SHh$Ri?de__L8r!aES)j9~J5EKJV7UfR zaa>VRvX?9yQ&XPolwL-%m0U)e>4KdmN@E#K5UV@Ec};AN1&8EDh}9!CaWqAq^G>Mv z`}2TrE;Zn;Tu(O(uOf_dJP7EZPjhQo)%g|>pXV# zeLc=jB$9;;EV?p%D#T4{`N(QRcd8rG^#glx?F71FmD!}al{QhFZjvtti8==)NR3IR z_C9cGCh{zX&x>GsN%JdtGZqhESNuLH9^@*QiX6uB+G~qPgsk3fWKG~E(bND&9ij3| zD)q{2OzTF6pB;)do_w}7qbj?7c~CrSD!{k z8J;ke`Xz!?+b­g1JpELG)(fT7QtHqX3`Q`L)>#E>ME#6;Y+)>OZXdu$YDg)vKEq)$hK zX~O3H2#H7GLOJRxWhB{;xWi1o4GxNE1ho$&@fFjrEOy+;oYnWo4y;P9+g_kxAEag9 z3~OsR!zI}9gh;l6nF~8LN3!=Rtsm@CVyiYo$!(PB=lD^!jE!Z14~o_K88OxQDw8m0 z4E@;d4;C2S+?V0)W-pN#KiwY!3o$gmM!hrN)u$z#UEwOhK&yoH=skILaO5Xnf{4kAHDu=)ME!lPpvs+C^b8A;%lf!+A%3h^zYdM zk6BXf+z+1OQWs;8ttRSXzgYQ?h@T(Zkx>eF#T|%%-9^i!lX-CLsVq@=fI?vaXSt!7 zNo~SJiKt;BhN-w3wJH|PYcFQR$9C_b=UxSbga@_Xr7r2dmxwAR>IVZ;hWI=J5zC?N zXjUS7A#}xqnu#;UEvpp+-@%BXGliSilvS_~v7Q zRL93gpw_2@?tyNo=ML00Z#~C#?ea4n#ShQrgMDzS-1B6q?U^XO{U=LHXbp;&1Tg2; z$7c|O{5@IqjVG1vFSilPG6>wmM-{!D-&s}1jfSTLlzLfSA8h#a(J>vIqw}@xc;ZXR z)}6Vd^CWvlkX|kZ)Tg3GUj| zyw}U_!tc5>^RSIO94EJrb&D&w3ucvURDq4NNnlzhIRCKx5r%4O$OxU7JHh5{XVwEY zK-s^7;7rHGzk*5eE_a+L1G0`eD4HC$rj({*VB(SLyRGzLBrPT#Y_rZ(s3tk5yVv$s zDPgbT53cC%%dNjx(ka2yr9mv2c+^xpiHuS20mKHn;xSv$^?7Ni*aUOm8AbZC|BI*;mKuBDa8s-!#mI!MN9X;reuF z*@RHsVG2PvnQ=4~L&D-2j*~~DG<3sZjWifzvBO4*pX*B`Wojj!;THSl=!O)vXnbf( zTiLm*04u~mTP&PDTNR#=0$pd~L+m`0$POq(cbL3)PTtAGZhFA{_aQDLt2m$+@%e;O!}VP3?pZYljrg6?&u&A?{=~ zqdN)qaAe4_8geHTib$iQ-_KO?(=SZz>QN`VI4oDim9;O$0L1BHD39nz(TBxVpSW(N zNyBsI8<w;sytHNHihS;5ac%oTWCMtr6x;pt9+ZB2uId+<~{_~9oPqmwj%8y9+ zHcB9GJHzyppcNJ$n&OWP_)J(muN&l9Rl2^|Fk6!k5Cz-1q~HnZ{w-SUPqRVZ@R6UZ znsQZ*K>{Xa?qbkw@4+p7X-_$ud4J**XY08&TE}3JTb8b0!Yv){KN)nTK7i+Or96Pg z-+QNURcPS*DwW6a!a|WunNeAry_^8mneFVc{~q=#YjS_Pwpec;Q^pBW3D67_yHsKu)Kp>={+<&CI z6w6@+R7&y`%?OH=u3@~Cy)j&{?U1Mq0h0aAD-ej_KbS$FR?3u~5nAxelyrv+B!LDM zgzV*irXz65^$3_5_y3nY0j(WHb@Qm0^zu%o)0{cT@qgaZ6e z(3*dDRodz=Qv#CdzdSDehe!};DfAE19|ufpW8^6#WyJXZkYQ0NgkwzL|8gJl4;2Z$ zN%)`2ynid(jy^e?ANNH`ChEA0`yBKVrducA_+qt053M`y~I>e9cA*$v29W z?J+{||Lv-K;Y655KtmTlwPH(G=UJLE4}v? zg7lIIVw3=r@9)j5H?!W%TQloTR_;G%-FwctpS}0z?EN|C_P-!)dr!h{Vn9O547vuQ z0D(Y!pf>M$#y3PD5T4=_yCgBdf&oiWiNG!iX=O4)CPR}^OQ zR(zqh8{2Y}S#Z}zH7lDZaW>TgZbX_MO$J{3+(Mld&x-nJ9rhDN`v!%Ms5~xa)@Tb@ zfAWyqSl0H@l!o=~2R_n}ekzXm$hffkXhH)06x=^Nc~LtkJeYwnt7Vid(WmVvJX@BHLpSqrhtQzD_)+K{7bp^s z1{Y#O|L(kyCchR>cZck987-a6`&>MS1k1`@zP>;d=>=Y2H^iDoms|{If1Fv_P7jp{ z?hiBcA|D{}c5bTjwP7Y^6Y!305-)8|WB(->LOs(N2Qoz)p*x3&*SX+QeasDeB#I>0 zOK*vF-6fcYhrB_QT$l)$fq2DA(t|L+yO3Jn&R;Ih2A6!In;Wgi&{e80pU zhEP=B@%8}svZ2JGe?r$+f`8A*Z<5qhr*6q6IqPc}m`%5BoE~CeEk(VdMN|{)H1E&W zcf>n87LXeJs>n_A6{Q%9Mzne8+Fi-5(iqDx-vSG%^IZMN=^-UmUv&#Ef|iQPE_(Y^l!x!_ zXFzuM4W}^YpUV5Sy5EIa%ng%pvS&NYQDBCOH$4d`J;rXs#n*QvJt!J-T4hq`pDM{b z<>;JQTv_CawCcW^;`Yuhf)6h)O=j|UD%9uo!n=a z=g2M^dD=_9%UvQBJI_A~pnnhrZl{Pq{}6*fP1ismI)djzy(L2Yo_jg_`FV*$eY{J} zmwcBL=_4dQUfsYr6dfVIK1a<oid#54pZ`=RP&|@rhz-CVlp~*p%MYT)ODnM9(y$ zKXLVtG%<54mGnp2Lu&J3z6iVI#e9U`C1*&++lunD)-1WU`DFbs+pEG@fdbz%eXizO z$pd*q<9z?{AGX(h8)sBPfY`d7*P9lI#~M8t_Mfn3CKgrRC%>&70H@F4Wj7uBYTEC_ z#oiR;$o&ga=gBEY`rMCinGm8PxwpM-zRV^2>UZ&TC+2{U(}P8Z>ZF&Q8K=nXvVKx1 z9j1xln&few^a)2KN5SXX4!62fPO~3zk)PSY7v0RTiaRCywZ6i8AAmFZDfRPA*5Yb0 z+UduyvSEs83=rS-)^f(%e$N6UZeN^@U%bc5<(|$FN7QhE^l^F;U!b})eUA%b45#p^h#tb7LaKlT;Jat zDk``_GwCioWJ_SrewW!&H_w}>52?fPGwvZfUYs)b;lck3j_cx}v8GKzV05s-$Kf1s z2^tkj6m)A?Y3=>c06c)k7|0HKe-K0M2p@`xE2qXv6DM&DTK17n2=zPp}FVq>N)R2g97#Gxk$m8j%IcdjSuWsj!j#V-2L zY7b))#c&tNhfbl>Vi3-~kO}FeDQKQeVO;^&;_1SEc*M9YXU$EF2JqEa02St*_5m>P zX;9~U5QWr58QA_=qKB&YV(G9w&T_I0l@EG+zA)!=5#fJxKkPXSb|3A{yb#PB{c^?8 ze$S(G+V(jaIKrD_%TaeY=uuSTPL1FC;c6DDed}=b&QpI zeRm+`Z_t)?Y2$^+Hy~!>MiPYj%cJZ4+{6qw=0oh{)2czvc%r37`gtKjoQT90rHa%?hWGxo{M=JAaQo_#K$VQq1pv>~Z2+6ISm;n&N*!r4PH@6OX>>O-^yQan*3m?%rvQh*}MKR z?eM)aJ@|#<%S8~tYsO#Wa{iX@nqH*5bJ~5w)-yeEi=%*CgG}#y$`7~w;u&5w&U63j ze;7XLOx6DWu_42mJ%ymLsrp=Xfy!l&KXEkE?Tt7+8`j(UHia)`5@jAL-eV3Z?Os*X zvKCJ%7NTZX9v;_NmVFeddjaVi*F3PXuaf!M9UJqG z=07?$RsI!Oj<*(Wow`@kk7V|WDWC^*?w`jg#?(!4F-_(Z>wnL05h801VO!Z!}rdC0Y|>eGFvX8j{ovU)(mmn{>9rPB~Umus*- z^nbrl_MAsSOg?7$O5m6alyGo368|$)TWLPtr~9qlWwk)Ze4X&Gw8DEg_di&LfBAgT z{LEnT)wy3m_@BxGExz6A>rFI7 zezZ%p8`s;55L2jLZs4lE77hnLr|Je(Z(Kt)9I)q%Qi^(;Iz}LL>^+nCgzhA>z?#gp zrc4Jb6&;y!e_Se0-&~fhHlA-~NBT;ZJri;Z9txoaKKv~5J$Sxx^Lf^6ZrmidpGK|t z4Nck`Dg0#H%%x1q#1_giF&Tr%zDOQ@Ypz!6ok*vx`JdclT`!)$?rU~Xs#|^B5rXL^i+*1IC!a{^tDr0;j`U&> zRs9B`QzxDt;~9z*Fq!YdXR7Mfc2v-6`S^D zg)|ju$}p;m`RVY*!n*o5>`H;1XyoQeO4|#fJciz88*ImA% z2i|Oll#A4`u0?meb?V>Dn^s&~{&vE3z1Aj|kJ#e5i)L!|;^T+26B4;?w@%&QXx63P zH?qbzDjO@>a_sCsq`dzknG&EnT$%Gh&el+kVZ<#naa{_}Es#E;CfAIz9hE7f6ZrF$ z>9&2j{p&t*sULwwRh}L^oJ^Cl*pNRg{vq#Q5@@&>TGTdr#w?U?8`YJ)e7j*whcm(xII$S1(Fj#$W zeIiDy6t6vnRKVq_@y)|j=U_G^I6XWIb`90pBgSupeTM0bQPuQ7sZ&E%V35fy2sgCe z7Qp;YP!;njuCe+FxQ+Q&x_zCM6&kG%UfN3s4L5LTiS--n@ zMJEvgm(p{AW*Y`qAZjnp-~@@fz};dKy5j#W!2bcc|Mf1{|FdcS!;?P{H0$YPE6_V# zzpWhUF&!f#WAO;}yM4Wv;K}m*(5*=yfh>=*jG59b8`r0y0>N$}&cg3b@6IU{}??9(kZDV0R^lcuDh92QC!Ya0u_8t3X){ob|U~fharbdyJFW z;$i9vaan67psPvvYZEqW)G_DfFp?6ti@r-TpeBoXn!X|Cw*I?!jL~zAu1Ofl2YZBp zEj~GgFd(^L`V4z*R?$JJ{P(dBbC60nEzDA{mOj>@uD!fzE&i}DV|d=tGdMSjeEJfe zAbb-ZFU(K4=Ki6VN!hF+4z6?jHak*BqO# zKnz!)PeFk4R2MP$fM5{WzDlotP4L34RTr8HGKm%y68f@F8P|+J7MKRSHi0f&dJ3L2 zVN9DZyC&5}-8$!31IW)JI^R6CKHYk$@3OQ-vG7XmUPd7&Xce9;bd!Jq1E4yErt9|6 zMUVBUbKt?ayb^ci`kvz#wyZ@cfPLo@j7z~Qionx<%8+*~6RDjr%EiYB=L30ji8qq1xF8bESBR88tDy73Qd*vTx%U3}wB`H4s+U zf;~S=#$F)X%b>6|Lr zxrql-^`iLKMS%V+BB&6WaSD5kV`9x-H}J!0B2>^^_4K=u+*r1rH5Tz`R62))QB_pL zpY>yQoX(nFdm6xudrt1hjN1y*YZ?((aQB7zY;e8f@QCS{gtPP^J{glnd1rC(XGwqC z8z!2*0>LpN3h*NlCV&WAKftwAeFa(!IlG6gk3Dq&`qaRfkmSf4Jy?mpzjS?_iMCeJ zh+FGdAZD02wll#SXu;EM04bO3NG#btbjSjOtdRR1uLj07*tbl{E|*P3q|wNm(3M5< z;5xg5^XVqVju57(B@eW68ctlULz)8~Sq7KM5L!ey_WHoaT2Cbs z;KBtsVBOL#X>cW9Ekg=u<nv^Gee zP9*WTU4Lw~MdDdR_Bz{3SuicK0P_Q;fQGOv?5UF$^zqXA02^}$<+(MB_h9DDGrd-? zVFDAE3XVfA*Is|{2(hx&E>&*M2I_%<^?hB?A3y8#%j=Xy1O(WEd`Ji>L~7I0igAxR z4UBDl#nz8K^1JP577UE}eKvnlBKqqJ#ORKs=$KQbE40S@VaE>OwRn20Wl_!YA}*jO zcO{R|LF3S$K;XqCGcFtjrilv4{#$VPqZG<{+&h4FOM(TV55bN&rV7BF5Fm}27pbb` zWiTzwSssR@TLHrQ%b0#`)hqH=B1*n?!#G_Um$l|NE9=LMcld}oSTwifCBp^O!Bl76 z=5B(zKVjAJ%;FLZ(ERg$2(zj~B~)i0eLAszx8nhfLEjpq znt*56!gQF!ip;}oE^6StYNFGsLFYI2*Vx374A3jk**wk$?U!H)A(b0r^YnLDewrP0u1LtH z9yL31;o{mv9XWi!yyK8)Y2#hi z?{s*bIV&4=b`7O3a5>Bjq%|cW$ja<+$>@!Z$f+z|MofBgErMes3D51N%<#dT$9e*X1B#i*qagUflNq<~Qv&eb{)+1NB_RlUz;z zvmgqM!WdkhJj)l&*chD+RY$2{^^bE`g~9F}>|A-)>#pl==>Q6JNSIWcxEip%G1m*G zhpFLO&&6;G`WU|$IWQS40QUh6PH+^R{YBNj12ZdxxUV%_f%*$lIY}>hC&U^9N>^=H zjWNj)3Ra!dP2b8J6E1~n8p8+jjvFy_wiw5E<;Zj>#Q3wbsttOEtoE^h2z0;KJ(==e zaIr{nT5=V$6SWDs%|&Jzd`$8VoKu`0ARmJ;B5&XlyVSYW-Ha2@)Mzl;+tHEI`xLZbDIL?NIP>qI6Se=Uxm+UYWUK)%RUKJOOkwGi;25iKJLKV-2UCD8?DB#`T>FeW`ojz+61pBKls zVWi_gu7jCAYq5mzBJ8l)U8_v7#u2&>Q-WE?hSQPcxT^hL(=jrH9qd7+7IaCZ zaI%~=RC=kAV9Aqy<*B12@ca-uB>y6`;;aZ4q7Z}7Syb;GvFf!=-Gh#uJ;W81l(()I z(BT@o$IiwmJV_imeH%nW!^=PsXcUc%5kQG^STp|g)Q@(jW_b1^>r)^3=`3fL?*c#d zHuH^bK|7rU2fk~A3+cN8vExnM&h>HVvyfSs6zUtEtuAt;fJIFNs?zJV-pLI0Gi#Yf zkOg3>H9ICm5jNEh4p6fVSX(+?^!&ok)|g`6oe3|QejjsIP@}gIUeDfm$qRy~n{Wt! z!{74R_yF!3Df3bTH#8D*n*Bba$J45Em3vl1m&*!FL4F$@x8)y6!qcT50jB7&cq9cj z{beNE{u)ywuyEX`POr+p!BuO#j%-4Y#f9m#qQTVA&r?RNGZH~`@qg1_s6Gy;-9hp- zPs*N;= zYkQ>(U0fD5vrl>w!$iwwq0bfxy4p1aFgNw?@!5_*o0?^JhJQZfZ9`_bgZGn3S zKA5S2xlY#o3LlH%%uc&x#{nj|x8-Xd!3ighZ8(e24LZ)Djdv;?%KZUB)nh0Q{@lq) zm%C^IiMA*e<3xg2_>u3@c+^9mQauj>i{B}r^vpIBm$O?x-%jaoe(@(_xZMZ6__8u2 zQ~WDW#XKHPCkuw(k>Ll3esHdJuaSDGv#Em7#|%4Hpauf5p?g-@=X~%)Xd^!q@9PL` zfELD;E$bOHmyR5lcHS=y9Wui7DqQk^Oms-sMkMN|oj5k6n?O{|&=Il=rteR);Da}S*=URoum9N;CJQt;YcZdW8n?DSY95?;aKlj@**TIlG+1cfElmX zGkC0uV=v<|F=INo=nWrUBk4uE4jFT7DevuUTSUzEIh~GZZd}V*zYkb9H{34$U`TNt zbTtcqZO$$X6GN+0xqrsB4Oz^Iiu%qCs0qC;%zyNm)a&35J|pfMwQ6KAXRPr{eCWm)2X4#`Gnam#O0&@!-N_b7 zx2ML93->9731J(<@Y%|Vy%#e5R)5tR2*{AQ|NgB;G1d6z=;iO`zsO{w)5JKn8&L5% z{q|&ZZjkN)2OHXr#@`O9_*8EtDJ?byF#l%e{#^zIet@B_vLeVizUq)?AR+`@1X>M1Z7 zI`9aa-%<*5YE!3&xnWxRF4?C70or-I(5!3$1J0~F1fcmP{5aMYSA;sgeFfUM)*4>1 zEBXELv(=lRzv^9JdQ~>J^-c;~dtACd1~Ur%q)g@LM3 zkQa`W&6t5iu?p<%x6EgMY12t3WQRGGoTm;aAIy6zx(11a?x~Dl`wiby1QYtbA;mqG z8cDF(Nf%PAu?frj?(WE3LeRb!)Fm@zMD?%5v`KHQ)6jQ*5uveLQ5#X}S965KNF0t< zdS=6cnzg8tUSS4~*0VKQjQVtPN4_o6&- zEk4&RQB{nf8X9BQx+UU~cQVe5tYP;$u@e1$qRhWv17^1 zHd>|b*)M7&kZw$l3r0#}ujI2uh+jGpQVR&YUsWIA4MNi`oDifIgzh@Pj{7^*g;d0b z^zb<05>YM5h{u=`R6!C<7xNqPgd%8+WIuNL>(v| zl0L>=D0o6eS+H!q5+nouY%z$SI+!@lzZyEw&EW8-z%#vv z_jV`du)nFWZ0wyxew)RQ%IuNs$PnZ@RVQ5|n8_H$bK4H!@nkjmG%atZTZ9V>O!xf| zR-5EDwQ9MFDpgr%&Jt0xFe&88#`EWkU4e>|K3u`aRW$%^n%`d`Gm7>o!mRxwO<2M1^Z=i&y5*87Tw?*5XO6=-oMyu;MH++ zYJZ<4@K3N1EH6(8lt4OWt@Sn55p{ymzTCu&b_mR-7eRvsT9ag}%QIGfBpU0L*t}w2 ze2{lbW2xlHv+^i)I944D7y@jz%XZKhJ*xpnA?HOP4sTIyhpJBiAtq0~mUMiTwBNVA zWGs{{r0u+9asXe#5O##%p-a00{dreN@?UPc|L>jA+I3w@Ogc^aP8_P53=<9?41eue zPv^8RA1dI)#cW8rwqWp|YO1-b8omw-Hoe#L3gEVqGGf-?F@|4hD#9-{Z_98)dd66H zEs=DSH?pRBhp~CO0d~+k{Z_B?7HdyZv*mM1&we^d()<`a=a%(rnwim1F@`H^^1}@@ z8UM$nqU1*c?bK@~WE+Q@jaV%`a)R7T)yPYMEt{ssddR=%=cYtQoAsk2;z8%#48=96L(rU~JC=4@FI+EUX( z!L1D42jj5O!NOe72b3}Ut|S!F^Q@yF*#cLMLa*LIbNCEpzww zdoW9O_c@|7!jqh1n1|sHURU1*0sqow5%6dccBuiF7;33j2f}9Gw^7fu`v4ZO5qEz3 zt$Zp^Rb~fRxppftLjLUAvf(B-wa~2;P!Is;*ENJg3|Qd(y1IZmimvktRCLmR1;R0* z#x9@ifC!GEb_Kdj9OELSR>q0yf3gYgMt^<<`U_Si)Y{Q%+*hD2$0$0S)-ge9f?+!^ zNpS&JptoTlv>F&{`*XWn*>D%F&bD|bPmA>ozH`TqcjeJ9x-3D=VQ)#O8UNASpGUnu z4wZ#G1$cP6z5-lVS4c5{mjY9EI1q#9e}i*Tnzo+h<1u1MyRJAscGzI zDS-?{ZLYj`qF=ez{ux6lKur!)dq~(!v3qtYhmD`?Lgj@$ZEF28PSZ5lSLUD;v#y2u zc3aYrZRm}*sx9iQGe@KZlmhy z3v;Vq&S7sZk2CguaxORNRAt{Ma!0u`7_>`3#q%K_5eOb)EF;P7*F(_6hCB#_z6{ms zS9nZYbbf9mKWGrDu$Ntb-V*UpUPZwhR*afSxOQ!wcIbZ^S&%R?fqvzCx>jXcSufeg zZ?MU?J$aKgM=T~Xp?V(TW5ltZ?e~`HGrz2NX;p^yzwE(a$OjL7$msWv8?E~NWmFBi z0>!+eyRSzdO`CVv-F?!8vwE(7KI5*#_Gz-AUurU+tCN16zXriZ|9xDY z|2Qr=A!%SY2q19uQUL+Pd3&gvW8CtJN0#Z5T@oS4WR{gZpDSz9`$=0_Z$3%2u9D)i zhNqdV0A>K2gS|a2M#+xA(2v@H6jh7TC6r$RMZ@H;cXzaXLxZAJsEK=p{$XhPTJR+R zBQSLQ?|&G&^q-LVFE-u#_s;%dX!=RFN#B(tyh#m`z|c3e&;Y01?IAw`L$6A^v|ve1 z8*91sr$z_e+TMQ;3J_?K9uX~sJDC~5bIq9k#m|%;R*rO&1Sz9;@F$P%^Cjq9zvZ*k zw%VUGgw1$7D|S;z>__jr<;L{Zg#|((3a2;Mg=?ELDHCW}ORtqc%SQt3*n8jA3A8Lz zL(me-YOep>l~3#DvV+iT`S{R3y{Ra+kxXI6(8H-y_2yr+JYgyTA2SsM2&}B|AVqst zz;29%HQivE=YGBl7V#;|K+l>y8N#6Yh>w3O?LKrFR##J+{0}RWd&uA*Jpp&OlP$K! zWkVevW5-f!H)w9>c^}-2p`#xlm5O=r;BlH_iM@b(C5t(MmH#uepZvcWrAF{ec3{w0O^Bmn_`6|#z^x$#KgPT#xV{j8I1Na?F z7A5Y^I91L1zS5N%N7A`Eb6iRPPmY^2syCBA8=;LNZEC+2^fD-AOj?E8IGFbcd_-jZ zH1M4;5F$5)Uz)4JgRO2$y~Ksr?~fB~l}tyn-||U#I(WI~1MZ>F=1SF?)MBck30u|mJ?otmT6EEJ`(KJN$Y^dWQ_p;cv^zOd`iZ)qqpcwUD+1PHt%=J2a=Ny}>pS6bOKzF#XS)dao0xOyBs(xqo$%|7y)^E>3-%r+K>b;b2wp36+)7wDDAPvpwRAD6y zcAC^0uUlh?4~`smNGjkGcDD$R-h^k^GK%?k(jmb(wexOeqnX(h=BdFTnx93@H1LV;7PJg~Y!6C3z@OWiwt?lrq`e$)$%h2et;&!lnYO51vCmdpLEI%;b>7jm* zB7CThqB_@oM>yMIcA}2r{~3G*^1;QL&B9U(<{!Bobo!kuy!#TmYL)k+uXE4@?&zQd z_i><=mQ!CSn1qY^gM^)nl1oMj{^4`&AANIw>kpKgy-)C+zf#+MkF$dp zL2GcVoirR{cT{yQU89~ojrI0 zE07sHasBz*=LF1^L*fF**ef_+4@*B(IXhJQJ9J5(e&;YNL>}pf7ihzC zTWg3sY|jps`r;-+M4NJM2t0BB`;eeGQ&<&Tyeprd54{3mGD00g<`11)PGI#19IBl% zLu)^dBi=P1d;1pBNWh&O6qKb^HP7{~K)&wEt0{zMAqzm$X{v$2xiMZK5?HtbHHvOE zp5O}(gkZ;lqbI8M@)9z>V^T86DD?&($92-{!Kv@v9C$z=EbL!rKcBg90q-mx)fIbd z*mHhde{3l$?k&6S934D1T)%eQE5?t`cwP1>`0i2V3#OKUlmO%l*p>PfENuC2YglN6 z^%d@8-ouQ;+L`qBUvr7zH8pRDqiFEnVeMSY5*XqKo>R93H(xb{ty~s#TwT`x25KRf z*uN1?VN1mE;CgU#XJ^M4^i0Er5UVlAUqLl<`_*4aD~f+Kae)`*{ga(SCQ8sCBuEI(l-^ zh6LV4E!VMEs%$@PSs*Lx_zeL|lGvWrX3tzC9?Iu6TWKRZ+JEQQkI(e%)mx$0>>AgB znz^e&uv)~$$GoWi{XPF6U9+{ezAL=_h-G^EjZBxZOJkFfiUAMp`yp}`Cu>!SWNYP9 z*|qAv5UYk?=xiXd-fyjo&MC3J`g}sZDuTM_^A zkxKk9=1%*1%H2t?kWw3RkOr+x3o`v;Hr zy`A?DoV|R};y5!IVZCAN+wo8a7u%%{3H_7H$Vbw=1ktgt4#zBXo~AD<(y zySaL320m{~k7!7D%_ui|{UqqEZ0P9E+Y;vv+_-kdZx!U9Qv$<}S6;T|?213V5dYaY z{JBbGNI+~K;c4BO;?>G}0&{zP^*5x3xj-!;E7JoQ*=wt5P_51A&%Hd=by zjI;h3jn8aVaZv0e<*4#`2CMSt!GxWWAvZ#Qqg@h z4^znP$fHkslhYorZ+l$dN)&Myweh&n^0brpu~VviM7{Tw-CXL!N%8kd!~@1hvZ4Vj zL~H1Cpu-C@tJr$6^Ca2wS)b#%slNoX23e-%mY&7Naq%b1(z`T65%HfLo}{Vvn@oHZZ6DR-GU zn^yEoejB+l*72N}Mdy;v+h>8vmJ0YDKZPy$74R6Px|7b|0H=F73a+ zw`c|&&;P-Gt%YsXiuR2+r){qeHZ3z6oI8ADQM5YYkbH@spL85#b*s|0uDl<6r|Z{> zWcX(t&&Q2x)OV?E8oURQLQOd?xAkjz5?N@5Z1sc7qw*e1mdCJo*YrP2zMHC|H-t*d z3^H{K%GmVCo6p$t5x+&4hG<1g6LTYVjE+1&VV^%6l((JrI#z3+qxDTgATi1_BiX{p zY);Q{;Suqj9S^a-njF`lELm&0ara!&kdYhIX%!u=K?5(orkqY^A&zjbR|hlZrhG}l zM6G@)#@k>qudn9 z9wC>a#lL{(xXI7Ua3}2*PXbG`<9v7Y^mbdSB>HxK1&@3P@34_7x)QZbw`5E-Uo(}{ zjTtQB%Xk5P^AQmmbJasRHMucR1w=D`hh=OA{;ia*F<6j1mkhi4yK*GN)+JqZ=Gorb z>#3(<<-u{qq!e8_ZYn7hRe#w{cvWf!w`cbXOsv9wxl|q8Yvir{E8bBJ+^V$Sn{i|M zVoMfi*F(Q@|Jjh`i>hebi>EOS8nkp0^+nHZJQbDi%IGVl&@j@z(ZR-fPr3qOUxi=C zeI+Ze>_93RXkA1+|M!86annVPq4KD^V=2-G zd)I$@iw)>GDVeC7L6EW^&E4Ku>bS>AVnas>^HR_?0rMwL%w09_-7=( zQU!l-q&E?)^{N%G+?o_95wS-E{AyH)CjwUN^8o`LggAjcJOAVh=OH8=+%YCT>3CMEzdUp^yb~MvJ^@T95fpG z`r>%enVeiPPvG;EMa8AImKiGRG&|?P`RL5&W}o{cTsMuYNtTB#y5j9?0$j8bc<=@* z_k6xZk!?n3G?#v?qDe~K15z6JBFx(KYy%&rl|D0ly|%NUf5%T)q)p8ux$$NsI!wHz zcO!-|B_)3*^-r0&&vQe~)Bp|XPr)p+Lw9CvhZBsm1wBVMf4)T@jNxP@UEaiY&Ab$b z=s7~>@g@%7fhv<%KF0V3HFsd1Nk4UBurTehF%C)%z5#VVJo$b*6lhjzJF9k2IJD}y z$p(FxByFa*%@pZ;eEIxMqk6W$it`RGf6T(xlyPsR1@T!a>{!JiZSc%(PC!E2m@Ya< zNslAvel1mNvDm&x*QEa={M4)b3OSFPhwmCY<*}*t&D5CGvk3*tjS*BmXYv#Nl0&*Z zvB~Q-w>#EfPR8DwVh2ihomOOa9&TyB9GrHx&)@V-$BcJq-gBy+W(bos3@TD8$Ny4g3o_?OBtR9PyI>&&VsLRZwio{36bZ-{P@~2Usz<~7O>}C zr^4TveA{?qL7?UYTlJy(z4cgNuTVn zkDH7PyF7+p3yrNsyWj9_jJ<+tJzaK8HNKcos!e=tpBM==`=txaoSDcVN7M!!So(Ic zHK!lC0#w%Hd~fl9tlUwfg#T%`sUcfjuzN*n#3$(1@|+)C3$TtSQ(kYii%ts=nW376zgB3hluh;Zq z)VK;s1HM|^b30Q?T7F?nV@HX3rT8_i`A+s_2O=X*TrQS{={ip~^=_lA8`-owgcZ5N zn%7!1_?2D$>!d~0H`~upvG!)7*jN1OM+^pnvbO^P5(=N4yA)d`uVE%@jAluu z(GwX-xy`kD*;P0H9#}PwO&(T&1Sjas@MQ-)O3NQP6{TaJ4rIGXhMFK?G*XebIGV4i zT^GIjL^$mCHs&MKgKf~0w`Fl3gU6{K4W6w&9xBXfHC)}ve@FSzW(ypCSnB>-L|l($ z$`#lL7GM zyhcox#!>x>&6s2d;mvO-?iub7=7$}Igpa1Q8c4iq;reoVIaMc1Ile0e&EHv65(w7e z+lVR%bRj2y^2UN&_WCMzOF9ZwDu^!``Z2KvY-|Oz$P=8iAQ&-kV7#6!^U@}o(OH@O zD9ZfGwwb?@@?(K_(Y)mBK;|aH5Ds`9SNDJn<83J#Nce2DnG2A*KQ;8(B-Z&Fy_56k z)xj6kS_Fw9=UpwF@XLPqJuwyL-n+7R$-eqQ(s9(At%u}^yzlwQotVEBdi3npURqdMH=gLxK)fzGR3Ik)s{Ex1dnvi53ZeriyW)}+LJP&SyM6YwFu zK0y5URn_PDgsMSjuIj;*)*0ahVm*0BUR~J$Q60DE&WbZ2qP)tNyjt9#&ky=N>NXfi z8CQnk^Z_iurw@v)GTWiqx4B-5I#gYIOKilX9I@jKlDT;}X&vxW`}yl9*>x8+P_&!2 zHAhz~?ITAi{v8^dx9kbIrPLySC9%H?HYSX#~X`M)m$0EA33@ z>O#r9&fe_;`p?5XiZEx|RAY|BZ0T#g-=yT=r41Flr(X=RA@3#^B*@i9xxV21l}gGi zM|MfA6hzua>{&RDWT!2WCl8u&hC3tv^v`E*9&2oqg2z(0K{}RM6t{mb9Ncd%6v$9* z`tT0HDtY50La`XVS(;^4x-FE4(Ub7@p?%X5;@;@DI{9v zYd`y#d&}ocEc38IrQ+OUVyZH+QW}jf|nz%jE(2``4WBLuvjXnDF$lHE;(}Q-~h*Unf2^p8w4aBi+F#siZ44dDo=;W z_xxI^`T7GvTnR~_I?8hAt!A|yd&;yt@txkq3!o59E&cpt)Yz43$0j*#!ryhjrB>YI zUYFh!zTjH$^&ciJo)tnN32~Iuwf@LYrZUkHri$!TNk8go$c94v*JUSKesMXle&eNjIC+P=QFx^nrLxt%>WB8N=uLxHnUa7%~ACl^GbV977mj3rBv*0KuNvVluG5asQUz8^cE7-4xed$Pvp`D&%bBm?w z&wDji{AV?zm}&29t#CWI(oV?Lz>xg$xd1r_(876d>6>oQuw4#*e9eJaHNCIB;Kq-E zPyXFg+}FRo$W6;s9wGYN?{_at*=p*>6PGS~{r8l_b>-ZTvzb|WI9IiVaFdWMqe7>X z_pxTn+1Af*l+rIS!*7YQ4y!~Pk`tGvfW+R!vZf|eOOrK5gZL58)eCt@MBArtb%30d zBmqt#$;$gm4U?yLKC#L^>>;6W&ON6>GT^uzsQf;B%;=TZe`p?P7$X~R`r_!>iO~JI zHSYae&Qgzol1|xoq{dsV6#4YkeZQ*J^*??y_-}1}1ymeOv-U2FvsiF<2p&ARI|L0O zcyNc{!3Kxm?iwIKfZ*=#POw05cX#;7_uYHn``zI0f1@}!=Ctm*Od2sgySYx zMByR(W(4|LOrE{WI1J@`=bE+ZYD6V*eF!mL&5vocNbd>e_;YN3U%jCYE!@rCwlKHQ zk){ad83j$j@%2^fL_j|J=#n)Y)z|5iFl~80pUh`qT3g(W4jN{}&UKka>TLXMbUXcD zbCh)-d<6{yc4yainWwz)?0^6Tq-U!j;{25=&-#zdDfcqrz@< zjm9^!!KEDrVlX@&o3Tqng$LmTjqDxIQU_K6B5BU-?U%L8w#7u-ZlBXy40&+ z+5F0h)?|ZDZGv#~x=%v4+b3$hSnR{8q*NUtZ(QmZDDWASYwb8PXUB8%>^ch-kSeWb|j7jc(LtcgD<4&EB3#Ctk4HE2n)VR!9%x38w7 zeus?%vK>K2=MtUoV-E*#nvREM5Rgy&X7UzXtA^!8IqgyL(PA94T#^lYJ9~V09N)Sk z4W%V87I2tb^WnaX`jBtTq-(!LMiQTQoOs=!t=*3Mkxy_Ic}BrLeFg90)6U4JO}OBX zdn4~?gGkKEbFC-lmsW*-Qjg7*OUmwqlDd;1XkTzFN3`Le?QL2Mm>yWCwBN1<(|aeF z6@^xk&ZcLrrbM|;LLTV4yt~`k#`r~YI8apd`7AiQAgMV*UGJT=@-}^%Ms9Uz-0A55 zoEB?N#0M}37h4n{ieDs207W07M?)kC-??UaWAEVatzbEy$hx-MVV@&i@b%NV%`$Zj zprb3T&&9+Kdl8-}SCSQ4ctr;H!7o|ivwi|4Nu?pip?NR@U`vXcsWk*+4K6M|^6~MY zB6=MEAd+$3ouZ*6pi)s2(XA&r#$qT6ikKXijb1pG`H~$6w&YM80U1&@zX@Fa4!RXE=3|~ zh5q6paF~x%w`lfM{N{C^*wD3(rJKIsPF_m^=}w+}k~Qk$S_EZ@HE7ZZyS;r}GgFuYF#-nIXtwckJc_d4c@R~>w`uVYXF`o>4i&>FYjirr$t6Zec{mjk?X=|47dg<8Nbbf; z))cDo1n?HI$cMoqr?)bLF)=mBxr`7;-;qvZdtA)h(C<+{seioHu<`kMF$QOxpWX8c z3CQ{M$}X0UHFzH3!{nP!*W92F@IkzUI=qYCPErOhu~$bKUpj-@m7dH8CdO#41ivYJ zY8t;)6b^h+Y1PJRSsOnskSzTk(KtIBB9<&~A+xYN%=+bijtkx3ZXwM(j+db&JleJRtFl1^*ni zWFCYRrnNdb_5Uy=ynn?QcXFB>1U2X*SWTz4&&wgFd!qpxdC*sGv?9ZX$d3-^4z|zJ z)(1_$Nu{yv3E}DsK`rg?v%tU1j@)Oap`#UPJk8Iu5^{C2q_0e=40W~+N(+}$XvU}3%VkP{^7 zyB%;UYSOxUqaN1b-%_w)cFzcUH?LN0Jofnq zpIds-qsX#4#xWc`M;;DW-#zol9PLFV96t*Gn@{Igo_b|990*is7&nfK1L)hO$zZfE zD>WYbxGCKly}_9O$)Z?VJY7s#L$}1(8`iQ1Bcxg9qIA7v=fYMo#pyhmVs-z970JMb zz?+|c7{sBFdCaisiD5&R=Dr6%<~fV$Ji%nrlG+Hgrs?PXoZ4;H+xk(|Grbfx>Lql4 znIv0qE!V7zl0&ld?dbcF7O+2(zwO+krT*o*WIlw@n?9{}kgKGYvFvv>rM}B|mHg)M z>ps1Np@l<_`jXH-C)Lfv`@^ko=06mFZi+D!UDvYC7KILdC~mYk4}?*16^+LeUv}Bl zyG~$Q_--Zl2yHx1t&9(>XEoU}A-&*Ci&re=FEFpI$!w(BSs-3L^8%JUOSZS@KyGtZ z+`B@&WDaoJVzX(Ap;BC>xxP?D++=2Fy|3O;cnz^(8mSQ`da^agJilFVw?4JWbrz+x z2vAA0j#yU)qU!S}J`18tIhkI;^1l@?nr1#8&kjVbLJDufwGj-)*)D&uZ3CBc6`G^> zAGw+yzfU{%e&OXhOzj9FL4 z-~K3aG=aA;|Ge<(`>Wy9qT<=?OMi_G?Iq&)PL8GJ-A8MbXakIugVvVx?Ve^2KVkKN zDug1%WekMN$Qe2Ov zoe!Wp@dz06=S``1t@DMCX*M+&hl^TT9-K|ThNIRO5`OKj-`UCi+>^tXhhLkA=dsC^ z%sEVGPmKuPKmypmB%_B@?2qy6bL^w)U&FoWk|t{RO8S zeRzK?TJ5qPJz{Utyww)UfGWnZt>@H-RfIDjc;=d=^ZP3>HtvoiWrp+Api;D-HN&g9 zaEr9dRz~3=UbNn*0rgg#Tlx9ETG;lC?$rX9yKCIZXge*H!3^0jU{Q3KQOQiLBlC${{yYa!wU!^bwV4H&twQgy8v(^iw8Rf$9SZzPqheIqI2 zo~?y3RfOOClG*TuVWxhB&9>kqQHen-R3<`^aI{n}7iXBGz&VIUc9DVO&+`-f_8&Wm zN=GEn59P)=2tjs{faCw}N21mdS!B?sUT(xN_g_1^egN`SGO~*p9Dj~qhH}TdLIXPW zay5oIdYprJWEZ(DQ?-uKLIX4Pat?+$0-S?zmO_d!OV7&kUb--=hXQaL9#)rbXk0yF zHo!&OI!kQmt#FP%E6~9e%n!m}g#gq|AS70iNtEat80t2R0al4K|IVz!Q}mbzG3qu< zmm|vCi0B6?8E-1;HpBr|v9qw~2g-jzsk5*OJapI>0J^HdKDZF#}uy6=>B_m)Va66rM(V zR>g6B>2$09%x#{Yf*?{&7T3Pmm8%ant#Srofy+Xj0dr3DgPz3~O~1(sjy~U_SH%BD z79qQ8j3FbmX-aPF+w?B$7U;p|e{A%JIXhXNuXWgaIzM9=_^ChI6*k=_$NDWMgthW! z?~XE3Pe)gOj6?W>NB_a&EC#ll?$tp7@k*c{dE)`Lr%aAu`hn<8U7wBGwee;ReZE~* zhdVhp_9)rAPJVAg!z;3X59MPJ8qeJqPMQU993lxZ&>;t5!w5R|JH~LZt12a@oR8PS z38+P>kvw1?iCk(otvnhIZEeA1HNjgjYP~%(>n}4~&cW3mkBv$m8h9HAGu|_~&X&}4 zc)s%v*)S}>luC>R@YxvF(YK()-DOc_Vcgo%qj$i8m0zC&eIJmv_TO}}jtWi1wU)&J z1#2l9Rvl=-?W-W;@o(t-$ur}>$Rc5S>M&-Apta*n3wEub|D)F6#J@O=xmj+6D>0dk?FZ7~4>H1l12De#xiMycKf0W2a$ z7$4ujFt8&I-2^hp#tskXOU|AMbE7<>sbyP6Ze5>yTGg5Y8@)!#(I%-6M8`uA1>}kf zI+c_3c;I^(+Se>Jn(U+%oW1njCojoR3=Oz=0ygf!&FG+dmNp=6>vT*u@6KtG#M66%2iD=&G9$snwxDF z@)d{5Rf)kL3+@ZjWTtQ{PFjnXu{x&#;uGfHQ4@jz3KCc+Zcas>@dgg~=tFbC|GpxyO@k1P)7KJyENH@j<;OrvCB9llxk z1xRp3Z0r|+un&3a+*4!wYI~K~;f1p&N!9S9*w1#pT7! zDqi(dKaL!Q$f(+)_F@Yxrlwq3OUqIUGPK&zDXpmRvyZNzwu9qZgh^rZhSk3$(S93{ z7Mxlw#h?5}^83?x^MfUJ**56rFz9xq6mU{oAY;?9y7JW~=>YZU*T1j$l@F`PBlknw z{|9aUku7?ff9X>>@0=xuWT1_62#j6L%kMJe8+>i5gl}D=gvywu&eceEsHsKRtXR9H zQbF(s5HS4A(Q5ExO-!o24u!Qq(zs_qtvca$Tay!q;0T0=#}W3{@v>b=Ev4@idJj4ueu-- zYM!pp$SsUQ#KfP2Y*!HvD%>Tkb1v<*R^?n;${%kE>2mEFfcC01xnDjO(gn3r;T$NLNxY!dsrnR>%joT3FS6}D*w*J-R(#hhPZM@2SCwsyfr z?xlZPV~SUZpvG*pi=90J%wJOjF;tQ?#nT<*gzl>Rt3y`36_Zo} zv2HXbC2d3imzd3fjtI?5hbzYK?x;(R36ox~!;fM9x#HD%QfM%1vfFD+sOdU280#X@3Y=k)r=^1tU0>~dAu zv}hoZrCQvlT|6NDqaE=qPQWr`Lm1IB%7UdbuDx<%>cE716o!R-88M{-RwkYT+4uZd zd?$0QRA^b?hq_sVd{z_AcGB|G-NWt(K-MM%Je*w|?Q8^-Mg0*FYI#1p?<)}gL!zsH z`FyiIk+yAzuGA*%d3SbkbF>3QjY+pX-d(pno;|Hj-2+!$U3~>StfZNl%OqYmSBGN& z8JTd~^U2Na>TNJ9ASBfCF!u7T?c>AA;bxZp^IPwy^ZoU%<1sQ)vNo?LC(pa}C}9%7 z`?LMUKI`$arT^TUSz z{5kmDXgz|NzzV{I(hi*?yu-?u%%$)K)bmAOano=E4s7%!;7M!6!`+xrnQ zHExn7GG5d%Pr*!jv=u#Kf83YZ?Fwc3Ch^`lNRy*Gwa0x=gLj6> z1uua^x&*$0u-g&?DE?a0$B~c<7Z#GuI^cshtbdg+Tr8P(>!OP;4A5E(y*(-6Gv;npfVmU%o@ zwS9kn&@i8wBxr&lHvbEy*pn5j>x}*#xy0hcY$T?uQyYKq{gN;I#A9M>?L|#s z+5KCm1(9x5I~n5FBm)+I`cy3*D{<~OpLS!k zURBiIig4Tu0!zoc-eaTlo5zLopK&WjZndpkZo|xLPntLJz+>8Oe>%@eGp|pYgSQ0* zj#nEx`j$Cw?)1sSRsBOxIy+q#Pq6lGct??(9|E+*9K}e4`x3{~mHU*MXgKMnSHx`z zJqHxAq!H78H5#Xi+(Z(-TSdcqMB`ng2;?`m4?c6i16)@q>!6T8{k$bYPijf;z};Q+6Fy1Z9=q> z54rcsq`fMfB#L(+rEybU9WeKI{@TZq>Fb8}J6nBEuy{0)*#-LdECd&sMe+$`4@}!Y z?$44I1Tgd9dC0th;@k^Z-SwkOCvi{ci$~RvBh7SKIf1S2;QmS{N(y^jzR-gTq+K#Z zqeef1-~E*NUB6wF>H1=j)Bfh|#$JI(`QUtR<38=+<3`PUSG6NLM{Z4<7n}c@eA`?- z(#`_8hn{3lw`{&j&>qk6b}dX|p7F({>%v9o!o6&gEWzbU@R%d`HiqF9w8J5hMR5n6 z@R&BWt@2Rc2Rqjxbdq>R0fJspr-VM?#8Y**mZb>nAOefPCjy^v1XKAxzL)r6;C{rs zuH-8bc=B~HqqPKEmNdD5w5!>Ti?SIqq^AgnTia=n@-ZTjGGn$I5OkZ4Sqq&iRz`VWHOoqj&Lv=Zg7Ng}u+Glfm^kZa5qmVK5g&c4q%LFUdP>hmLa?(Es4_w~!xIkS z_vg5x8THik&hIWlqXX!TIjI0uS$Cn$(WUc&5cSwhrLAg{Z&~kSjCVVbndI2v zyoZIRx_CB>qk- zY%*rCNW~@cqlS8XZ(n#9j=sR;M7VD!mpl094Hi@H?l(h>c=mP0Wmtu=G;aUUw!X!$ z(9J5JJFm#e;4GL9`AR|FVtpG8uzeea2;p1jUL9cJs{U$SIPc`ap=swmC{bh-6uKB2M(xks?&3FfTt9-;X9CQ`$Hp+J3BxPM)$|mWb^OK$Fg%*!>Bu z0$(19`%}kb2v^ZWZVbVmpe0O4lCgg8WJZE$V->s1wHy|1XvLBDqM*n7sK?&PrWPg8 zOe|)!dc?1HmJ;XGHrcMI885R@CW|H7pdB>}T)Lne9j77T0Ti;D4ZFAy1KF%C{|@-w zAfw5G^kyAu>hyH{Z=!r4KtWUHeIKgPt~JL1>5;RE5z{V|4g*SqmtJ1py{j>-+4%j3 za^VxSABTI|Jpt2F5K<{yc)&oV?t+7upbNLgX+_)cE2okpPTY zp0h$Pd>>tW{CZw~(J5Ir?gPC$D!n!rGHQm$fFc@ZhFW<*@Z88-;4|um&G2sEMw#l- z8E9!!=g47$-^q57=;KN~n4OvvBXVP0wdQ@KlWXLL77LBurp(t5nDnQMO11^@ZZ9Kp zUUxAuDPdmI`Hr;(i{0eXmy6+;qn{2JQtFs3nC~U*Byc90BCn4R>RvAClPaK$!@i}SA`yyd$g z{Mh7}K7 z$voGTIW=bvOwdbNbkwt`%Sk^;=a5cSNDDUav1vy8!ZeL*pJ#WWVa(W~->@z4{kO7# z8zZ~4+&eqTNE}uzZp=Ze_?}UbLS|+M(}0D^HB%{p&mZTS$NR88n8-Mr%9ux_$C*`J z7>y2a$PaRE1NQvzV>!WZipSsJziJfS-e8Wruuh;Nd11!%b{hLqo!`q@tSqb{F~})> zwz$ov#V}<_lW!uKS6#jHc0u04!n-}@YEp2Uml5Y@-(Zu!P<0Y1qhsD&wPyLA*vNXt z_)Cbf;$vwZ@sE&rahw>3LP}M%FBbwp-ucTFL|#ad0xzw3&eA^%Ah*O^TW-m)?p3f$ zGtfjOw8<64Gf3ZUhswkqq(A7&VCwR!B59SaQGVc4S`UyLUqEBDV2yw<7NM3NuE<2} zPB=E@^w9$*5`ZPR46Ul&#{#?Dgkv=Znh8pA*|P&LESk zM!VYq8|nFYHPBUQWI7^}10etW;%Q(%&?)opRfL^sHq`F$crz4qJxRK&3?UHjN-~oj zn9pclln+E>Pm6z=?2r>9w0bR`<3}Z2Bxz&nLxmbM!h6t>_qygIVkCAxDPx(qDs+Bs zV}O`YZU5(R$Z}`Z=K&~^hv1S96V1V;lM25w?+WiU10;u#y)Hlgx6(!YYMDrL<_B`U zF-DBC?XBEAOCfd)*5xe-EpL<}{F?54Q`Gvb{=mZv`{-ZiEG!1AA$e8%Ivp6$m+yLm z-LnkWCO+Vi_T=lFSPMxIwM^1Q* zRlO>Q`x;qn!#6MVa|7det=7H#27x>^RYa_EHWhv~Ls^-_f~mTN+vE>88(#den7jdV z?d+Bso1lsu4~%ZuQHl&rM&=N}`9n(=bI!3b!dtX1I9vlHs>Bu2ojNScjOg%p{a4~V z5FZsNDq{4^%IlDmx>-Nmtyw?O6kfQxzL^oHP<}HGzRnXX*rsCmC^*ysP#B+zIW#8m; z_c@{5wUDib!uhvzAHT>R9TjsitiO?a9M6!%Su&R08`aKQm-Zs_^28|Me5UyRKHl_{ zU4D(=6#ClH^Hg_`HICv55BZ-=SaD)cDtsdl5J=y_#M+US;GqiiyL`jCi=hmhW@7-O#A=i#|MG%{^M+8+you4ILwk-LJpXL_@BkS|5r<~=D)Pq8^I+xL%>8 j<0V5B=7029(VLX>Vlp<|OEd%o!g?u(FIss9{vQ25$sAwH diff --git a/Orange/distance/tests/test_distance.py b/Orange/distance/tests/test_distance.py index b485dd23f31..37db5f04f02 100644 --- a/Orange/distance/tests/test_distance.py +++ b/Orange/distance/tests/test_distance.py @@ -1,6 +1,7 @@ import unittest import numpy as np +from math import sqrt from Orange.data import ContinuousVariable, DiscreteVariable, Domain, Table from Orange import distance @@ -145,12 +146,11 @@ def test_euclidean_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/3, 2/3, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 5/9, 1 - 3/9, 1 - 5/9])) + [1 - 5/9, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, np.sqrt(np.array([[0, 2, 3], [2, 0, 2], @@ -161,12 +161,12 @@ def test_euclidean_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/2, 1/2, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1/2, 1/2, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1] + ]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 2/4, 1 - 3/9, 1 - 5/9])) + [1 - 2/4, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, np.sqrt(np.array([[0, 2.5, 3], [2.5, 0, 1.5], @@ -177,12 +177,11 @@ def test_euclidean_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1, 0, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1, 0, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 1, 1 - 3/9, 1 - 5/9])) + [1 - 1, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, np.sqrt(np.array([[0, 2, 2], [2, 0, 1], @@ -194,12 +193,11 @@ def test_euclidean_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/2, 1/2, 1, 1], - [3/4, 2/4, 1, 3/4], - [3/4, 1/4, 1, 1] - ])) + [[1/2, 1/2, 1, 1], + [3/4, 2/4, 1, 3/4], + [3/4, 1/4, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 2/4, 1 - 6/16, 1 - 10/16])) + [1 - 2/4, 1 - 6/16, 1 - 10/16]) assert_almost_equal(dist, np.sqrt(np.array([[0, 2.5, 2.5, 2.5], [2.5, 0, 0.5, 1.5], @@ -223,19 +221,19 @@ def test_euclidean_cont(self): dist = distance.Euclidean(data, axis=1, normalize=False) assert_almost_equal( dist, - np.array([[0, 4.472135955, 2.236067977, 6.164414003], - [4.472135955, 0, 5.385164807, 6.480740698], - [2.236067977, 5.385164807, 0, 6.403124237], - [6.164414003, 6.480740698, 6.403124237, 0]])) + [[0, 4.472135955, 2.236067977, 6.164414003], + [4.472135955, 0, 5.385164807, 6.480740698], + [2.236067977, 5.385164807, 0, 6.403124237], + [6.164414003, 6.480740698, 6.403124237, 0]]) data.X[0, 0] = np.nan dist = distance.Euclidean(data, axis=1, normalize=False) assert_almost_equal( dist, - np.array([[0, 5.099019514, 4.795831523, 4.472135955], - [5.099019514, 0, 5.916079783, 6], - [4.795831523, 5.916079783, 0, 6.403124237], - [4.472135955, 6, 6.403124237, 0]])) + [[0, 5.099019514, 4.795831523, 4.472135955], + [5.099019514, 0, 5.916079783, 6], + [4.795831523, 5.916079783, 0, 6.403124237], + [4.472135955, 6, 6.403124237, 0]]) def test_euclidean_cont_normalized(self): assert_almost_equal = np.testing.assert_almost_equal @@ -243,51 +241,51 @@ def test_euclidean_cont_normalized(self): model = distance.Euclidean(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["means"], np.array([2, 2.75, 1.5])) - assert_almost_equal(params["vars"], np.array([9, 2.1875, 1.25])) + assert_almost_equal(params["means"], [2, 2.75, 1.5]) + assert_almost_equal(params["vars"], [9, 2.1875, 1.25]) assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) - assert_almost_equal(params["dist_missing2"], np.ones(3)) + assert_almost_equal(params["dist_missing2"], [1, 1, 1]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 1.654239383, 1.146423008, 1.621286967], - [1.654239383, 0, 2.068662631, 3.035242727], - [1.146423008, 2.068662631, 0, 1.956673562], - [1.621286967, 3.035242727, 1.956673562, 0]])) + [[0, 1.654239383, 1.146423008, 1.621286967], + [1.654239383, 0, 2.068662631, 3.035242727], + [1.146423008, 2.068662631, 0, 1.956673562], + [1.621286967, 3.035242727, 1.956673562, 0]]) dist = distance.Euclidean(data, axis=1, normalize=True) assert_almost_equal( dist, - np.array([[0, 1.654239383, 1.146423008, 1.621286967], - [1.654239383, 0, 2.068662631, 3.035242727], - [1.146423008, 2.068662631, 0, 1.956673562], - [1.621286967, 3.035242727, 1.956673562, 0]])) + [[0, 1.654239383, 1.146423008, 1.621286967], + [1.654239383, 0, 2.068662631, 3.035242727], + [1.146423008, 2.068662631, 0, 1.956673562], + [1.621286967, 3.035242727, 1.956673562, 0]]) data.X[1, 0] = np.nan model = distance.Euclidean(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["means"], np.array([3, 2.75, 1.5])) - assert_almost_equal(params["vars"], np.array([8, 2.1875, 1.25])) + assert_almost_equal(params["means"], [3, 2.75, 1.5]) + assert_almost_equal(params["vars"], [8, 2.1875, 1.25]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 1.806733438, 1.146423008, 1.696635326], - [1.806733438, 0, 2.192519751, 2.675283697], - [1.146423008, 2.192519751, 0, 2.019547333], - [1.696635326, 2.675283697, 2.019547333, 0]])) + [[0, 1.806733438, 1.146423008, 1.696635326], + [1.806733438, 0, 2.192519751, 2.675283697], + [1.146423008, 2.192519751, 0, 2.019547333], + [1.696635326, 2.675283697, 2.019547333, 0]]) data.X[0, 0] = np.nan model = distance.Euclidean(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["means"], np.array([4, 2.75, 1.5])) - assert_almost_equal(params["vars"], np.array([9, 2.1875, 1.25])) + assert_almost_equal(params["means"], [4, 2.75, 1.5]) + assert_almost_equal(params["vars"], [9, 2.1875, 1.25]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 1.874642823, 1.521277659, 1.276154939], - [1.874642823, 0, 2.248809209, 2.580143961], - [1.521277659, 2.248809209, 0, 1.956673562], - [1.276154939, 2.580143961, 1.956673562, 0]])) + [[0, 1.874642823, 1.521277659, 1.276154939], + [1.874642823, 0, 2.248809209, 2.580143961], + [1.521277659, 2.248809209, 0, 1.956673562], + [1.276154939, 2.580143961, 1.956673562, 0]]) def test_euclidean_cols(self): assert_almost_equal = np.testing.assert_almost_equal @@ -296,25 +294,25 @@ def test_euclidean_cols(self): dist = distance.Euclidean(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 8.062257748, 4.242640687], - [8.062257748, 0, 5.196152423], - [4.242640687, 5.196152423, 0]])) + [[0, 8.062257748, 4.242640687], + [8.062257748, 0, 5.196152423], + [4.242640687, 5.196152423, 0]]) data.X[1, 1] = np.nan dist = distance.Euclidean(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 6.218252702, 4.242640687], - [6.218252702, 0, 2.581988897], - [4.242640687, 2.581988897, 0]])) + [[0, 6.218252702, 4.242640687], + [6.218252702, 0, 2.581988897], + [4.242640687, 2.581988897, 0]]) data.X[1, 0] = np.nan dist = distance.Euclidean(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 6.218252702, 5.830951895], - [6.218252702, 0, 2.581988897], - [5.830951895, 2.581988897, 0]])) + [[0, 6.218252702, 5.830951895], + [6.218252702, 0, 2.581988897], + [5.830951895, 2.581988897, 0]]) def test_euclidean_cols_normalized(self): assert_almost_equal = np.testing.assert_almost_equal @@ -323,25 +321,25 @@ def test_euclidean_cols_normalized(self): dist = distance.Euclidean(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 2.455273959, 0.649839392], - [2.455273959, 0, 2.473176308], - [0.649839392, 2.473176308, 0]])) + [[0, 2.455273959, 0.649839392], + [2.455273959, 0, 2.473176308], + [0.649839392, 2.473176308, 0]]) data.X[1, 1] = np.nan dist = distance.Euclidean(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 2, 0.649839392], - [2, 0, 1.704275472], - [0.649839392, 1.704275472, 0]])) + [[0, 2, 0.649839392], + [2, 0, 1.704275472], + [0.649839392, 1.704275472, 0]]) data.X[1, 0] = np.nan dist = distance.Euclidean(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 2, 1.450046001], - [2, 0, 1.704275472], - [1.450046001, 1.704275472, 0]])) + [[0, 2, 1.450046001], + [2, 0, 1.704275472], + [1.450046001, 1.704275472, 0]]) def test_euclidean_mixed(self): assert_almost_equal = np.testing.assert_almost_equal @@ -349,26 +347,23 @@ def test_euclidean_mixed(self): model = distance.Euclidean(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["means"], - np.array([1/3, 3, 1, 0, 0, 0])) - assert_almost_equal(params["vars"], - np.array([8/9, 8/3, 2/3, -1, -1, -1])) + assert_almost_equal(params["means"], [1/3, 3, 1, 0, 0, 0]) + assert_almost_equal(params["vars"], [8/9, 8/3, 2/3, -1, -1, -1]) assert_almost_equal(params["dist_missing"], - np.array([[0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [1/3, 2/3, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9])) + [1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 2.828427125, 2.121320344], - [2.828427125, 0, 2.828427125], - [2.121320344, 2.828427125, 0]])) + [[0, 2.828427125, 2.121320344], + [2.828427125, 0, 2.828427125], + [2.121320344, 2.828427125, 0]]) def test_two_tables(self): assert_almost_equal = np.testing.assert_almost_equal @@ -377,24 +372,22 @@ def test_two_tables(self): normalize=True) assert_almost_equal( dist, - np.array([[1.17040218, 0.47809144], - [2.78516478, 1.96961039], - [1.28668394, 0.79282497], - [1.27179413, 1.54919334]])) + [[1.17040218, 0.47809144], + [2.78516478, 1.96961039], + [1.28668394, 0.79282497], + [1.27179413, 1.54919334]]) model = distance.Euclidean(normalize=True).fit(self.cont_data) dist = model(self.cont_data, self.cont_data2) assert_almost_equal( dist, - np.array([[1.17040218, 0.47809144], - [2.78516478, 1.96961039], - [1.28668394, 0.79282497], - [1.27179413, 1.54919334]])) + [[1.17040218, 0.47809144], + [2.78516478, 1.96961039], + [1.28668394, 0.79282497], + [1.27179413, 1.54919334]]) dist = model(self.cont_data2) - assert_almost_equal( - dist, - np.array([[0, 0.827119692], [0.827119692, 0]])) + assert_almost_equal(dist, [[0, 0.827119692], [0.827119692, 0]]) class ManhattanDistanceTest(FittedDistanceTest, CommonNormalizedTests): @@ -433,48 +426,45 @@ def test_manhattan_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/3, 2/3, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 5/9, 1 - 3/9, 1 - 5/9])) + [1 - 5/9, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, - np.array([[0, 2, 3], - [2, 0, 2], - [3, 2, 0]])) + [[0, 2, 3], + [2, 0, 2], + [3, 2, 0]]) data.X[1, 0] = np.nan model = distance.Manhattan().fit(data) dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/2, 1/2, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1/2, 1/2, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1 ]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 2/4, 1 - 3/9, 1 - 5/9])) + [1 - 2/4, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, - np.array([[0, 2.5, 3], - [2.5, 0, 1.5], - [3, 1.5, 0]])) + [[0, 2.5, 3], + [2.5, 0, 1.5], + [3, 1.5, 0]]) data.X[0, 0] = np.nan model = distance.Manhattan().fit(data) dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1, 0, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[1, 0, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 1, 1 - 3/9, 1 - 5/9])) + [1 - 1, 1 - 3/9, 1 - 5/9]) assert_almost_equal(dist, - np.array([[0, 2, 2], - [2, 0, 1], - [2, 1, 0]])) + [[0, 2, 2], + [2, 0, 1], + [2, 1, 0]]) data = self.disc_data4 data.X[:2, 0] = np.nan @@ -482,17 +472,16 @@ def test_manhattan_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["dist_missing"], - np.array([[1/2, 1/2, 1, 1], - [3/4, 2/4, 1, 3/4], - [3/4, 1/4, 1, 1] - ])) + [[1/2, 1/2, 1, 1], + [3/4, 2/4, 1, 3/4], + [3/4, 1/4, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1 - 2/4, 1 - 6/16, 1 - 10/16])) + [1 - 2/4, 1 - 6/16, 1 - 10/16]) assert_almost_equal(dist, - np.array([[0, 2.5, 2.5, 2.5], - [2.5, 0, 0.5, 1.5], - [2.5, 0.5, 0, 2], - [2.5, 1.5, 2, 0]])) + [[0, 2.5, 2.5, 2.5], + [2.5, 0, 0.5, 1.5], + [2.5, 0.5, 0, 2], + [2.5, 1.5, 2, 0]]) def test_manhattan_cont(self): assert_almost_equal = np.testing.assert_almost_equal @@ -501,28 +490,28 @@ def test_manhattan_cont(self): dist = distance.Manhattan(data, axis=1, normalize=False) assert_almost_equal( dist, - np.array([[0, 7, 6, 9], - [7, 0, 5, 16], - [6, 5, 0, 13], - [9, 16, 13, 0]])) + [[0, 7, 6, 9], + [7, 0, 5, 16], + [6, 5, 0, 13], + [9, 16, 13, 0]]) data.X[1, 0] = np.nan dist = distance.Manhattan(data, axis=1, normalize=False) assert_almost_equal( dist, - np.array([[0, 7, 6, 9], - [7, 0, 3, 14], - [6, 3, 0, 13], - [9, 14, 13, 0]])) + [[0, 7, 6, 9], + [7, 0, 3, 14], + [6, 3, 0, 13], + [9, 14, 13, 0]]) data.X[0, 0] = np.nan dist = distance.Manhattan(data, axis=1, normalize=False) assert_almost_equal( dist, - np.array([[0, 10, 10, 8], - [10, 0, 7, 13], - [10, 7, 0, 13], - [8, 13, 13, 0]])) + [[0, 10, 10, 8], + [10, 0, 7, 13], + [10, 7, 0, 13], + [8, 13, 13, 0]]) def test_manhattan_cont_normalized(self): assert_almost_equal = np.testing.assert_almost_equal @@ -530,51 +519,51 @@ def test_manhattan_cont_normalized(self): model = distance.Manhattan(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["medians"], np.array([1.5, 4.5, 1.5])) - assert_almost_equal(params["mads"], np.array([1.5, 2, 1])) + assert_almost_equal(params["medians"], [1.5, 4.5, 1.5]) + assert_almost_equal(params["mads"], [1.5, 2, 1]) assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) assert_almost_equal(params["dist_missing2"], np.ones(3)) dist = model(data) assert_almost_equal( dist, - np.array([[0, 2.416666667, 1.833333333, 3], - [2.416666667, 0, 1.75, 5.416666667], - [1.833333333, 1.75, 0, 4.166666667], - [3, 5.416666667, 4.166666667, 0]])) + [[0, 2.416666667, 1.833333333, 3], + [2.416666667, 0, 1.75, 5.416666667], + [1.833333333, 1.75, 0, 4.166666667], + [3, 5.416666667, 4.166666667, 0]]) dist = distance.Manhattan(data, axis=1, normalize=True) assert_almost_equal( dist, - np.array([[0, 2.416666667, 1.833333333, 3], - [2.416666667, 0, 1.75, 5.416666667], - [1.833333333, 1.75, 0, 4.166666667], - [3, 5.416666667, 4.166666667, 0]])) + [[0, 2.416666667, 1.833333333, 3], + [2.416666667, 0, 1.75, 5.416666667], + [1.833333333, 1.75, 0, 4.166666667], + [3, 5.416666667, 4.166666667, 0]]) data.X[1, 0] = np.nan model = distance.Manhattan(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["medians"], np.array([2, 4.5, 1.5])) - assert_almost_equal(params["mads"], np.array([1, 2, 1])) + assert_almost_equal(params["medians"], [2, 4.5, 1.5]) + assert_almost_equal(params["mads"], [1, 2, 1]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 2.75, 2, 4], - [2.75, 0, 1.25, 5.75], - [2, 1.25, 0, 5], - [4, 5.75, 5, 0]])) + [[0, 2.75, 2, 4], + [2.75, 0, 1.25, 5.75], + [2, 1.25, 0, 5], + [4, 5.75, 5, 0]]) data.X[0, 0] = np.nan model = distance.Manhattan(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["medians"], np.array([4.5, 4.5, 1.5])) - assert_almost_equal(params["mads"], np.array([2.5, 2, 1])) + assert_almost_equal(params["medians"], [4.5, 4.5, 1.5]) + assert_almost_equal(params["mads"], [2.5, 2, 1]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 2.75, 2.5, 2], - [2.75, 0, 1.75, 3.75], - [2.5, 1.75, 0, 3.5], - [2, 3.75, 3.5, 0]])) + [[0, 2.75, 2.5, 2], + [2.75, 0, 1.75, 3.75], + [2.5, 1.75, 0, 3.5], + [2, 3.75, 3.5, 0]]) def test_manhattan_cols(self): assert_almost_equal = np.testing.assert_almost_equal @@ -583,25 +572,25 @@ def test_manhattan_cols(self): dist = distance.Manhattan(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 20, 7], - [20, 0, 15], - [7, 15, 0]])) + [[0, 20, 7], + [20, 0, 15], + [7, 15, 0]]) data.X[1, 1] = np.nan dist = distance.Manhattan(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 19, 7], - [19, 0, 14], - [7, 14, 0]])) + [[0, 19, 7], + [19, 0, 14], + [7, 14, 0]]) data.X[1, 0] = np.nan dist = distance.Manhattan(data, axis=0, normalize=False) assert_almost_equal( dist, - np.array([[0, 17, 9], - [17, 0, 14], - [9, 14, 0]])) + [[0, 17, 9], + [17, 0, 14], + [9, 14, 0]]) def test_manhattan_cols_normalized(self): @@ -611,25 +600,25 @@ def test_manhattan_cols_normalized(self): dist = distance.Manhattan(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 4.5833333, 2], - [4.5833333, 0, 4.25], - [2, 4.25, 0]])) + [[0, 4.5833333, 2], + [4.5833333, 0, 4.25], + [2, 4.25, 0]]) data.X[1, 1] = np.nan dist = distance.Manhattan(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 4.6666667, 2], - [4.6666667, 0, 4], - [2, 4, 0]])) + [[0, 4.6666667, 2], + [4.6666667, 0, 4], + [2, 4, 0]]) data.X[1, 0] = np.nan dist = distance.Manhattan(data, axis=0, normalize=True) assert_almost_equal( dist, - np.array([[0, 5.5, 4], - [5.5, 0, 4], - [4, 4, 0]])) + [[0, 5.5, 4], + [5.5, 0, 4], + [4, 4, 0]]) def test_manhattan_mixed(self): assert_almost_equal = np.testing.assert_almost_equal @@ -638,26 +627,23 @@ def test_manhattan_mixed(self): data.X[2, 0] = 2 # prevent mads[0] = 0 model = distance.Manhattan(axis=1, normalize=True).fit(data) params = model.fit_params - assert_almost_equal(params["medians"], - np.array([1, 3, 1, 0, 0, 0])) - assert_almost_equal(params["mads"], - np.array([1, 2, 1, -1, -1, -1])) + assert_almost_equal(params["medians"], [1, 3, 1, 0, 0, 0]) + assert_almost_equal(params["mads"], [1, 2, 1, -1, -1, -1]) assert_almost_equal(params["dist_missing"], - np.array([[0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [1/3, 2/3, 1, 1], - [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1] - ])) + [[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [1/3, 2/3, 1, 1], + [2/3, 2/3, 1, 2/3], + [2/3, 1/3, 1, 1]]) assert_almost_equal(params["dist_missing2"], - np.array([1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9])) + [1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9]) dist = model(data) assert_almost_equal( dist, - np.array([[0, 4.5, 4.5], - [4.5, 0, 5], - [4.5, 5, 0]])) + [[0, 4.5, 4.5], + [4.5, 0, 5], + [4.5, 5, 0]]) def test_two_tables(self): assert_almost_equal = np.testing.assert_almost_equal @@ -666,24 +652,22 @@ def test_two_tables(self): normalize=True) assert_almost_equal( dist, - np.array([[1.3333333, 0.25], - [3.75, 2.6666667], - [2.5, 2.0833333], - [1.6666667, 2.75]])) + [[1.3333333, 0.25], + [3.75, 2.6666667], + [2.5, 2.0833333], + [1.6666667, 2.75]]) model = distance.Manhattan(normalize=True).fit(self.cont_data) dist = model(self.cont_data, self.cont_data2) assert_almost_equal( dist, - np.array([[1.3333333, 0.25], - [3.75, 2.6666667], - [2.5, 2.0833333], - [1.6666667, 2.75]])) + [[1.3333333, 0.25], + [3.75, 2.6666667], + [2.5, 2.0833333], + [1.6666667, 2.75]]) dist = model(self.cont_data2) - assert_almost_equal( - dist, - np.array([[0, 1.083333333], [1.083333333, 0]])) + assert_almost_equal(dist, [[0, 1.083333333], [1.083333333, 0]]) def test_manhattan_mixed_cols(self): self.assertRaises(ValueError, @@ -692,6 +676,158 @@ def test_manhattan_mixed_cols(self): distance.Manhattan(axis=0).fit, self.mixed_data) +class CosineDistanceTest(FittedDistanceTest, CommonFittedTests): + Distance = distance.Cosine + + def test_cosine_disc(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.disc_data + data.X = np.array([[1, 0, 0], + [0, 1, 1], + [1, 3, 0]], dtype=float) + + model = distance.Cosine().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["means"], [2 / 3, 2 / 3, 1 / 3]) + assert_almost_equal(params["vars"], [-1, -1, -1]) + assert_almost_equal(params["dist_missing2"], [2 / 3, 2/ 3, 1 / 3]) + assert_almost_equal(dist, 1 - np.cos(np.array([[0, 0, 1 / sqrt(2)], + [0, 0, 0.5], + [1 / sqrt(2), 0.5, 0]]))) + + data.X[1, 1] = np.nan + model = distance.Cosine().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["means"], [2 / 3, 1 / 2, 1 / 3]) + assert_almost_equal(params["vars"], [-1, -1, -1]) + assert_almost_equal(params["dist_missing2"], [2 / 3, 1 / 2, 1 / 3]) + assert_almost_equal( + dist, + 1 - np.cos(np.array([[0, 0, 1 / sqrt(2)], + [0, 0, 0.5 / sqrt(1.5) / sqrt(2)], + [1 / sqrt(2), 0.5 / sqrt(1.5) / sqrt(2), 0]]))) + + data.X = np.array([[1, 0, 0], + [0, np.nan, 1], + [1, np.nan, 1], + [1, 3, 1]]) + model = distance.Cosine().fit(data) + dist = model(data) + params = model.fit_params + assert_almost_equal(params["means"], [0.75, 0.5, 0.75]) + assert_almost_equal(dist, [[0, 0, 0.1934216, 0.1620882], + [0, 0, 0.2852968, 0.2397554], + [0.1934216, 0.2852968, 0, 0.3885234], + [0.1620882, 0.2397554, 0.3885234, 0]]) + + def test_cosine_cont(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Cosine(data, axis=1) + assert_almost_equal( + dist, + [[0, 0.257364665, 0.398820559, 0.200841332], + [0.257364665, 0, 0.100822814, 0.002790265], + [0.398820559, 0.100822814, 0, 0.362758445], + [0.200841332, 0.002790265, 0.362758445, 0]] + ) + + data.X[1, 0] = np.nan + dist = distance.Cosine(data, axis=1) + assert_almost_equal( + dist, + [[0, 0.2630893, 0.3988206, 0.2008413], + [0.2630893, 0, 0.2433986, 0.1789183], + [0.3988206, 0.2433986, 0, 0.3627584], + [0.2008413, 0.1789183, 0.3627584, 0]]) + + data.X[0, 0] = np.nan + dist = distance.Cosine(data, axis=1) + assert_almost_equal( + dist, + [[0, 0.2424135, 0.3347198, 0.3207717], + [0.2424135, 0, 0.2580666, 0.2240018], + [0.3347198, 0.2580666, 0, 0.3627584], + [0.3207717, 0.2240018, 0.3627584, 0]]) + + def test_cosine_mixed(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.mixed_data + data.X = np.array([[1, 3, 2, 1, 0, 0], + [-1, 5, 0, 0, 1, 1], + [1, 1, 1, 1, 3, 0]], dtype=float) + + model = distance.Cosine(axis=1).fit(data) + params = model.fit_params + assert_almost_equal(params["means"], [1/3, 3, 1, 2/3, 2/3, 1/3]) + assert_almost_equal(params["vars"], [8/9, 8/3, 2/3, -1, -1, -1]) + assert_almost_equal(params["dist_missing2"], + [1/9, 9, 1, 2/3, 2/3, 1/3]) + dist = model(data) + assert_almost_equal( + dist, + [[0, 0.2243992, 0.3092643], + [0.2243992, 0, 0.0879649], + [0.3092643, 0.0879649, 0]]) + + def test_two_tables(self): + assert_almost_equal = np.testing.assert_almost_equal + self.cont_data.X[1, 0] = np.nan + self.cont_data2.X[1, 0] = np.nan + + dist = distance.Cosine(self.cont_data, self.cont_data2) + assert_almost_equal( + dist, + [[0.2931168, 0.231869], + [0.1011388, 0.1670357], + [0.3988206, 0.3092643], + [0.3389322, 0.2943107]]) + + model = distance.Cosine().fit(self.cont_data) + dist = model(self.cont_data, self.cont_data2) + assert_almost_equal( + dist, + [[0.2931168, 0.231869], + [0.1011388, 0.1670357], + [0.3988206, 0.3092643], + [0.3389322, 0.2943107]]) + + dist = model(self.cont_data2) + assert_almost_equal(dist, [[0, 0.26717482], [0.26717482, 0]]) + + + def test_cosine_cols(self): + assert_almost_equal = np.testing.assert_almost_equal + data = self.cont_data + + dist = distance.Cosine(data, axis=0, normalize=False) + assert_almost_equal( + dist, + [[0, 0.0413781, 0.3701989], + [0.0413781, 0, 0.150811], + [0.3701989, 0.150811, 0]]) + + data.X[1, 1] = np.nan + dist = distance.Cosine(data, axis=0, normalize=False) + assert_almost_equal( + dist, + [[0, 0.1289953, 0.3701989], + [0.1289953, 0, 0.3062882], + [0.3701989, 0.3062882, 0]]) + + data.X[1, 0] = np.nan + data.X[1, 2] = 2 + dist = distance.Cosine(data, axis=0, normalize=False) + assert_almost_equal( + dist, + [[0, 0.2184396, 0.3456646], + [0.2184396, 0, 0.4001047], + [0.3456646, 0.4001047, 0]]) + + class JaccardDistanceTest(unittest.TestCase, CommonFittedTests): Distance = distance.Jaccard @@ -708,7 +844,7 @@ def test_jaccard_rows(self): assert_almost_equal = np.testing.assert_almost_equal model = distance.Jaccard().fit(self.data) - assert_almost_equal(model.fit_params["ps"], np.array([0.75, 0.5, 0.75])) + assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[0, 2/3, 1/3, 0], @@ -730,7 +866,7 @@ def test_jaccard_rows(self): def test_jaccard_cols(self): assert_almost_equal = np.testing.assert_almost_equal model = distance.Jaccard(axis=0).fit(self.data) - assert_almost_equal(model.fit_params["ps"], np.array([0.75, 0.5, 0.75])) + assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[0, 1/4, 1/2], @@ -742,7 +878,7 @@ def test_jaccard_cols(self): [np.nan, 0, 1], [1, 1, 0]]) model = distance.Jaccard(axis=0).fit(self.data) - assert_almost_equal(model.fit_params["ps"], np.array([0.5, 2/3, 0.75])) + assert_almost_equal(model.fit_params["ps"], [0.5, 2/3, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[0, 0.4, 0.25], From 6ae811f68c6971e934cfe1aa9230853caf86c2db Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 15:28:54 +0200 Subject: [PATCH 04/27] distances: Fix blunders --- Orange/distance/__init__.py | 192 +-- Orange/distance/_distance.c | 1568 ++++++++++++------------ Orange/distance/_distance.pyx | 13 +- Orange/distance/tests/calculation.xlsx | Bin 66630 -> 67107 bytes Orange/distance/tests/test_distance.py | 125 +- 5 files changed, 976 insertions(+), 922 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 33a0d9c9adb..f59eba11ce2 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -2,11 +2,12 @@ from scipy import stats import sklearn.metrics as skl_metrics + from Orange import data from Orange.misc import DistMatrix -from Orange.preprocess import SklImpute from Orange.distance import _distance from Orange.statistics import util +from Orange.preprocess import SklImpute __all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', '`SpearmanR', 'SpearmanRAbsolute', 'PearsonR', 'PearsonRAbsolute', 'Mahalanobis', @@ -17,7 +18,13 @@ def _preprocess(table): """Remove categorical attributes and impute missing values.""" if not len(table): return table - return SklImpute()(table) + new_domain = data.Domain( + [a for a in table.domain.attributes if a.is_continuous], + table.domain.class_vars, + table.domain.metas) + new_data = table.transform(new_domain) + new_data = SklImpute()(new_data) + return new_data def _orange_to_numpy(x): @@ -44,7 +51,14 @@ def __new__(cls, e1=None, e2=None, axis=1, **kwargs): if e1 is None: return self - # Backwards compatibility with SKL-based instances + # Handling sparse data and maintaining backwards compatibility with + # old-style calls + if not hasattr(e1, "domain") \ + or hasattr(e1, "is_sparse") and e1.is_sparse(): + fallback = fallbacks.get(self.__class__.__name__, None) + if fallback: + return fallback(e1, e2, axis, + impute=kwargs.get("impute", False)) model = self.fit(e1) return model(e1, e2) @@ -133,8 +147,7 @@ def fit_rows(self, x, n_vals): class EuclideanModel(FittedDistanceModel): - name = "Euclidean" - supports_sparse = False + supports_sparse = True # via fallback distance_by_cols = _distance.euclidean_cols distance_by_rows = _distance.euclidean_rows @@ -168,10 +181,10 @@ def fit_rows(self, x, n_vals): else: means[col] = util.nanmean(column) vars[col] = util.nanvar(column) - if vars[col] == 0: - vars[col] = -2 if self.normalize: dist_missing2[col] = 1 + if vars[col] == 0: + vars[col] = -2 else: dist_missing2[col] = 2 * vars[col] if np.isnan(dist_missing2[col]): @@ -185,20 +198,19 @@ def fit_cols(self, x, n_vals): super().fit_cols(x, n_vals) means = np.nanmean(x, axis=0) vars = np.nanvar(x, axis=0) - if np.isnan(vars).any() or not vars.all(): + if self.normalize and (np.isnan(vars).any() or not vars.all()): raise ValueError("some columns are constant or have no values") return dict(means=means, vars=vars, normalize=int(self.normalize)) class ManhattanModel(FittedDistanceModel): - supports_sparse = False + supports_sparse = True # via fallback distance_by_cols = _distance.manhattan_cols distance_by_rows = _distance.manhattan_rows class Manhattan(FittedDistance): ModelType = ManhattanModel - name = "Manhattan" def __new__(cls, *args, **kwargs): kwargs.setdefault("normalize", False) @@ -226,10 +238,10 @@ def fit_rows(self, x, n_vals): else: medians[col] = np.nanmedian(column) mads[col] = np.nanmedian(np.abs(column - medians[col])) - if mads[col] == 0: - mads[col] = -2 if self.normalize: dist_missing2[col] = 1 + if mads[col] == 0: + mads[col] = -2 else: dist_missing2[col] = 2 * mads[col] return dict(medians=medians, mads=mads, @@ -240,7 +252,7 @@ def fit_cols(self, x, n_vals): super().fit_cols(x, n_vals) medians = np.nanmedian(x, axis=0) mads = np.nanmedian(np.abs(x - medians), axis=0) - if np.isnan(mads).any() or not mads.all(): + if self.normalize and (np.isnan(mads).any() or not mads.all()): raise ValueError( "some columns have zero absolute distance from median, " "or no values") @@ -248,7 +260,7 @@ def fit_cols(self, x, n_vals): class CosineModel(FittedDistanceModel): - supports_sparse = False + supports_sparse = True # via fallback distance_by_rows = _distance.cosine_rows distance_by_cols = _distance.cosine_cols @@ -279,8 +291,6 @@ def fit_rows(self, x, n_vals): else: means[col] = util.nanmean(column) vars[col] = util.nanvar(column) - if vars[col] == 0: - vars[col] = -2 dist_missing2[col] = means[col] ** 2 if np.isnan(dist_missing2[col]): dist_missing2[col] = 0 @@ -298,7 +308,6 @@ class JaccardModel(FittedDistanceModel): class Jaccard(FittedDistance): ModelType = JaccardModel - name = "Jaccard" def fit_rows(self, x, n_vals): return { @@ -310,22 +319,21 @@ def fit_rows(self, x, n_vals): class SpearmanDistance(Distance): + supports_sparse = False + """ Generic Spearman's rank correlation coefficient. """ - def __init__(self, absolute, name): + def __init__(self, absolute): """ Constructor for Spearman's and Absolute Spearman's distances. Args: absolute (boolean): Whether to use absolute values or not. - name (str): Name of the distance Returns: If absolute=True return Spearman's Absolute rank class else return Spearman's rank class. """ self.absolute = absolute - self.name = name - self.supports_sparse = False def __call__(self, e1, e2=None, axis=1, impute=False): x1 = _orange_to_numpy(e1) @@ -350,27 +358,26 @@ def __call__(self, e1, e2=None, axis=1, impute=False): dist = DistMatrix(dist) return dist -SpearmanR = SpearmanDistance(absolute=False, name='Spearman') -SpearmanRAbsolute = SpearmanDistance(absolute=True, name='Spearman absolute') +SpearmanR = SpearmanDistance(absolute=False) +SpearmanRAbsolute = SpearmanDistance(absolute=True) class PearsonDistance(Distance): + supports_sparse = False + """ Generic Pearson's rank correlation coefficient. """ - def __init__(self, absolute, name): + def __init__(self, absolute): """ Constructor for Pearson's and Absolute Pearson's distances. Args: absolute (boolean): Whether to use absolute values or not. - name (str): Name of the distance Returns: If absolute=True return Pearson's Absolute rank class else return Pearson's rank class. """ self.absolute = absolute - self.name = name - self.supports_sparse = False def __call__(self, e1, e2=None, axis=1, impute=False): x1 = _orange_to_numpy(e1) @@ -393,80 +400,117 @@ def __call__(self, e1, e2=None, axis=1, impute=False): dist = DistMatrix(dist) return dist -PearsonR = PearsonDistance(absolute=False, name='Pearson') -PearsonRAbsolute = PearsonDistance(absolute=True, name='Pearson absolute') +PearsonR = PearsonDistance(absolute=False) +PearsonRAbsolute = PearsonDistance(absolute=True) -class MahalanobisDistance(Distance): - """Mahalanobis distance.""" - def __init__(self, data=None, axis=1, name='Mahalanobis'): - self.name = name - self.supports_sparse = False - self.axis = None - self.VI = None - if data is not None: - self.fit(data, axis) +class Mahalanobis(Distance): + supports_sparse = False def fit(self, data, axis=1): - """ - Compute the covariance matrix needed for calculating distances. - - Args: - data: The dataset used for calculating covariances. - axis: If axis=1 we calculate distances between rows, if axis=0 we - calculate distances between columns. - """ x = _orange_to_numpy(data) if axis == 0: x = x.T - self.axis = axis try: c = np.cov(x.T) except: raise MemoryError("Covariance matrix is too large.") try: - self.VI = np.linalg.inv(c) + vi = np.linalg.inv(c) except: raise ValueError("Computation of inverse covariance matrix failed.") + return MahalanobisModel(axis, getattr(self, "impute", False), vi) - def __call__(self, e1, e2=None, axis=None, impute=False): - assert self.VI is not None, \ - "Mahalanobis distance must be initialized with the fit() method." - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) +class MahalanobisModel(DistanceModel): + def __init__(self, axis, impute, vi): + super().__init__(axis) + self.impute = impute + self.vi = vi - if axis is not None: - assert axis == self.axis, \ - "Axis must match its value at initialization." + def __call__(self, e1, e2=None, impute=None): + # backward compatibility + if impute is not None: + self.impute = impute + return super().__call__(e1, e2) + + def compute_distances(self, x1, x2): if self.axis == 0: x1 = x1.T if x2 is not None: x2 = x2.T - if not x1.shape[1] == self.VI.shape[0] or \ - x2 is not None and not x2.shape[1] == self.VI.shape[0]: + if x1.shape[1] != self.vi.shape[0] or \ + x2 is not None and x2.shape[1] != self.vi.shape[0]: raise ValueError('Incorrect number of features.') dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric='mahalanobis', VI=self.VI) - if np.isnan(dist).any() and impute: + x1, x2, metric='mahalanobis', VI=self.vi) + if np.isnan(dist).any() and self.impute: dist = np.nan_to_num(dist) + return dist + + +# Backward compatibility + +class MahalanobisDistance: + def __new__(self, data=None, axis=1, _='Mahalanobis'): + if data is None: + return MahalanobisDistance + return Mahalanobis().fit(data, axis) + + +# Fallbacks for distances in sparse data +# To be removed as the corresponding functionality is implemented above + + +class SklDistance: + def __init__(self, metric, name, supports_sparse): + """ + Args: + metric: The metric to be used for distance calculation + name (str): Name of the distance + supports_sparse (boolean): Whether this metric works on sparse data + or not. + """ + self.metric = metric + self.name = name + self.supports_sparse = supports_sparse + + def __call__(self, e1, e2=None, axis=1, impute=False): + """ + :param e1: input data instances, we calculate distances between all + pairs + :type e1: :class:`Orange.data.Table` or + :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` + :param e2: optional second argument for data instances if provided, + distances between each pair, where first item is from e1 and + second is from e2, are calculated + :type e2: :class:`Orange.data.Table` or + :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` + :param axis: if axis=1 we calculate distances between rows, if axis=0 + we calculate distances between columns + :type axis: int + :param impute: if impute=True all NaN values in matrix are replaced + with 0 + :type impute: bool + :return: the matrix with distances between given examples + :rtype: :class:`Orange.misc.distmatrix.DistMatrix` + """ + x1 = _orange_to_numpy(e1) + x2 = _orange_to_numpy(e2) + if axis == 0: + x1 = x1.T + if x2 is not None: + x2 = x2.T + dist = skl_metrics.pairwise.pairwise_distances( + x1, x2, metric=self.metric) if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, self.axis) + dist = DistMatrix(dist, e1, e2, axis) else: dist = DistMatrix(dist) return dist - -# Only retain this to raise errors on use. Remove in some future version. -class __MahalanobisDistanceError(MahalanobisDistance): - def _raise_error(self, *args, **kwargs): - raise RuntimeError( - "Invalid use of MahalanobisDistance.\n" - "Create a new MahalanobisDistance instance first, e.g.\n" - ">>> metric = MahalanobisDistance(data)\n" - ">>> dist = metric(data)" - ) - fit = _raise_error - __call__ = _raise_error -Mahalanobis = __MahalanobisDistanceError() +fallbacks = dict(Euclidean=SklDistance('euclidean', 'Euclidean', True), + Manhattan=SklDistance('manhattan', 'Manhattan', True), + Cosine=SklDistance('cosine', 'Cosine', True), + Jaccard=SklDistance('jaccard', 'Jaccard', False)) diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index f07148cd1c9..4d42094089c 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -1738,7 +1738,6 @@ static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mode[] = "mode"; static const char __pyx_k_name[] = "name"; static const char __pyx_k_ndim[] = "ndim"; -static const char __pyx_k_ones[] = "ones"; static const char __pyx_k_pack[] = "pack"; static const char __pyx_k_row1[] = "row1"; static const char __pyx_k_row2[] = "row2"; @@ -1941,7 +1940,6 @@ static PyObject *__pyx_n_s_not1_unk2; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_obj; -static PyObject *__pyx_n_s_ones; static PyObject *__pyx_n_s_p_nonzero; static PyObject *__pyx_n_s_pack; static PyObject *__pyx_n_s_ps; @@ -2076,7 +2074,7 @@ static PyObject *__pyx_codeobj__36; static PyObject *__pyx_codeobj__38; static PyObject *__pyx_codeobj__40; -/* "Orange/distance/_distance.pyx":20 +/* "Orange/distance/_distance.pyx":19 * * # This function is unused, but kept here for any future use * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< @@ -2100,7 +2098,7 @@ static void __pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_m int __pyx_t_11; __Pyx_RefNannySetupContext("_check_division_by_zero", 0); - /* "Orange/distance/_distance.pyx":22 + /* "Orange/distance/_distance.pyx":21 * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): * cdef int col * for col in range(dividers.shape[0]): # <<<<<<<<<<<<<< @@ -2111,7 +2109,7 @@ static void __pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_m for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_col = __pyx_t_2; - /* "Orange/distance/_distance.pyx":23 + /* "Orange/distance/_distance.pyx":22 * cdef int col * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< @@ -2140,15 +2138,15 @@ __pyx_t_8.strides[0] = __pyx_v_x.strides[0]; __pyx_tmp_idx += __pyx_tmp_shape; if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) { PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)"); - __PYX_ERR(0, 23, __pyx_L1_error) + __PYX_ERR(0, 22, __pyx_L1_error) } __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride; } -__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 23, __pyx_L1_error) +__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; @@ -2162,14 +2160,14 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } if (__pyx_t_9) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { - __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; @@ -2183,34 +2181,34 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } if (__pyx_t_7) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_11 = ((!__pyx_t_5) != 0); __pyx_t_3 = __pyx_t_11; __pyx_L6_bool_binop_done:; if (__pyx_t_3) { - /* "Orange/distance/_distance.pyx":24 + /* "Orange/distance/_distance.pyx":23 * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< * * */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 24, __pyx_L1_error) + __PYX_ERR(0, 23, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":23 + /* "Orange/distance/_distance.pyx":22 * cdef int col * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< @@ -2220,7 +2218,7 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p } } - /* "Orange/distance/_distance.pyx":20 + /* "Orange/distance/_distance.pyx":19 * * # This function is unused, but kept here for any future use * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< @@ -2241,7 +2239,7 @@ __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p __Pyx_RefNannyFinishContext(); } -/* "Orange/distance/_distance.pyx":27 +/* "Orange/distance/_distance.pyx":26 * * * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< @@ -2263,7 +2261,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi Py_ssize_t __pyx_t_8; __Pyx_RefNannySetupContext("_lower_to_symmetric", 0); - /* "Orange/distance/_distance.pyx":29 + /* "Orange/distance/_distance.pyx":28 * cdef void _lower_to_symmetric(double [:, :] distances): * cdef int row1, row2 * for row1 in range(distances.shape[0]): # <<<<<<<<<<<<<< @@ -2274,7 +2272,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row1 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":30 + /* "Orange/distance/_distance.pyx":29 * cdef int row1, row2 * for row1 in range(distances.shape[0]): * for row2 in range(row1): # <<<<<<<<<<<<<< @@ -2285,7 +2283,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row2 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":31 + /* "Orange/distance/_distance.pyx":30 * for row1 in range(distances.shape[0]): * for row2 in range(row1): * distances[row2, row1] = distances[row1, row2] # <<<<<<<<<<<<<< @@ -2300,7 +2298,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi } } - /* "Orange/distance/_distance.pyx":27 + /* "Orange/distance/_distance.pyx":26 * * * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< @@ -2312,7 +2310,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi __Pyx_RefNannyFinishContext(); } -/* "Orange/distance/_distance.pyx":34 +/* "Orange/distance/_distance.pyx":33 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -2354,21 +2352,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 1); __PYX_ERR(0, 34, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 1); __PYX_ERR(0, 33, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 2); __PYX_ERR(0, 34, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 2); __PYX_ERR(0, 33, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 3); __PYX_ERR(0, 34, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 3); __PYX_ERR(0, 33, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 34, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 33, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -2380,19 +2378,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 34, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 33, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 34, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 35, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 34, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -2485,93 +2483,93 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 34, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 34, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":39 + /* "Orange/distance/_distance.pyx":38 * fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 39, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":40 + /* "Orange/distance/_distance.pyx":39 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 40, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":41 + /* "Orange/distance/_distance.pyx":40 * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 41, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":42 + /* "Orange/distance/_distance.pyx":41 * double [:] means = fit_params["means"] * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 42, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":43 + /* "Orange/distance/_distance.pyx":42 * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_4; - /* "Orange/distance/_distance.pyx":50 + /* "Orange/distance/_distance.pyx":49 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -2583,7 +2581,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_v_n_rows1 = __pyx_t_5; __pyx_v_n_cols = __pyx_t_6; - /* "Orange/distance/_distance.pyx":51 + /* "Orange/distance/_distance.pyx":50 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -2592,7 +2590,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":52 + /* "Orange/distance/_distance.pyx":51 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -2603,35 +2601,35 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":53 + /* "Orange/distance/_distance.pyx":52 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< * distances = np.zeros((n_rows1, n_rows2), dtype=float) * */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); } @@ -2639,7 +2637,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":52 + /* "Orange/distance/_distance.pyx":51 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -2648,28 +2646,28 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 52, __pyx_L1_error) + __PYX_ERR(0, 51, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":54 + /* "Orange/distance/_distance.pyx":53 * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing) == len(dist_missing2) * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * * with nogil: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); @@ -2677,27 +2675,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); __pyx_t_1 = 0; __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 54, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 54, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":56 + /* "Orange/distance/_distance.pyx":55 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -2711,7 +2709,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":57 + /* "Orange/distance/_distance.pyx":56 * * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -2722,7 +2720,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":58 + /* "Orange/distance/_distance.pyx":57 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -2737,7 +2735,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_row2 = __pyx_t_18; - /* "Orange/distance/_distance.pyx":59 + /* "Orange/distance/_distance.pyx":58 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< @@ -2746,7 +2744,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":60 + /* "Orange/distance/_distance.pyx":59 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -2757,7 +2755,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":61 + /* "Orange/distance/_distance.pyx":60 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -2768,7 +2766,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":62 + /* "Orange/distance/_distance.pyx":61 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -2777,7 +2775,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":61 + /* "Orange/distance/_distance.pyx":60 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -2786,7 +2784,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":63 + /* "Orange/distance/_distance.pyx":62 * if vars[col] == -2: * continue * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -2802,7 +2800,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_v_val1 = __pyx_t_24; __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":64 + /* "Orange/distance/_distance.pyx":63 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2820,7 +2818,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_L14_bool_binop_done:; if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":65 + /* "Orange/distance/_distance.pyx":64 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -2830,7 +2828,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_29 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":64 + /* "Orange/distance/_distance.pyx":63 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2840,7 +2838,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":66 + /* "Orange/distance/_distance.pyx":65 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -2851,7 +2849,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_30 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":67 + /* "Orange/distance/_distance.pyx":66 * d += dist_missing2[col] * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< @@ -2861,7 +2859,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_v_ival1 = ((int)__pyx_v_val1); __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":68 + /* "Orange/distance/_distance.pyx":67 * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -2871,7 +2869,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":69 + /* "Orange/distance/_distance.pyx":68 * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< @@ -2882,7 +2880,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_32 = __pyx_v_ival2; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":68 + /* "Orange/distance/_distance.pyx":67 * elif vars[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -2892,7 +2890,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":70 + /* "Orange/distance/_distance.pyx":69 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2902,7 +2900,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":71 + /* "Orange/distance/_distance.pyx":70 * d += dist_missing[col, ival2] * elif npy_isnan(val2): * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< @@ -2913,7 +2911,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_34 = __pyx_v_ival1; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":70 + /* "Orange/distance/_distance.pyx":69 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -2923,7 +2921,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":72 + /* "Orange/distance/_distance.pyx":71 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -2933,7 +2931,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":73 + /* "Orange/distance/_distance.pyx":72 * d += dist_missing[col, ival1] * elif ival1 != ival2: * d += 1 # <<<<<<<<<<<<<< @@ -2942,7 +2940,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":72 + /* "Orange/distance/_distance.pyx":71 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -2952,7 +2950,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } __pyx_L16:; - /* "Orange/distance/_distance.pyx":66 + /* "Orange/distance/_distance.pyx":65 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -2962,7 +2960,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":74 + /* "Orange/distance/_distance.pyx":73 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -2972,7 +2970,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (__pyx_v_normalize != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":75 + /* "Orange/distance/_distance.pyx":74 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -2982,7 +2980,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":76 + /* "Orange/distance/_distance.pyx":75 * elif normalize: * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -2993,7 +2991,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_36 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_35 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_36 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":75 + /* "Orange/distance/_distance.pyx":74 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3003,7 +3001,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L17; } - /* "Orange/distance/_distance.pyx":77 + /* "Orange/distance/_distance.pyx":76 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3013,7 +3011,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":78 + /* "Orange/distance/_distance.pyx":77 * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -3024,7 +3022,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_38 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_37 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_38 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":77 + /* "Orange/distance/_distance.pyx":76 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3034,7 +3032,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L17; } - /* "Orange/distance/_distance.pyx":80 + /* "Orange/distance/_distance.pyx":79 * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 * else: * d += ((val1 - val2) ** 2 / vars[col]) / 2 # <<<<<<<<<<<<<< @@ -3047,7 +3045,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } __pyx_L17:; - /* "Orange/distance/_distance.pyx":74 + /* "Orange/distance/_distance.pyx":73 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -3057,7 +3055,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":82 + /* "Orange/distance/_distance.pyx":81 * d += ((val1 - val2) ** 2 / vars[col]) / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3068,7 +3066,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":83 + /* "Orange/distance/_distance.pyx":82 * else: * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3079,7 +3077,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_41 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_40 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_41 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":82 + /* "Orange/distance/_distance.pyx":81 * d += ((val1 - val2) ** 2 / vars[col]) / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3089,7 +3087,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L18; } - /* "Orange/distance/_distance.pyx":84 + /* "Orange/distance/_distance.pyx":83 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3099,7 +3097,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":85 + /* "Orange/distance/_distance.pyx":84 * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3110,7 +3108,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_43 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_42 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_43 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":84 + /* "Orange/distance/_distance.pyx":83 * if npy_isnan(val1): * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3120,7 +3118,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU goto __pyx_L18; } - /* "Orange/distance/_distance.pyx":87 + /* "Orange/distance/_distance.pyx":86 * d += (val1 - means[col]) ** 2 + vars[col] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3136,7 +3134,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_L10_continue:; } - /* "Orange/distance/_distance.pyx":88 + /* "Orange/distance/_distance.pyx":87 * else: * d += (val1 - val2) ** 2 * distances[row1, row2] = d # <<<<<<<<<<<<<< @@ -3150,7 +3148,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":56 + /* "Orange/distance/_distance.pyx":55 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -3168,7 +3166,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":89 + /* "Orange/distance/_distance.pyx":88 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3178,7 +3176,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":90 + /* "Orange/distance/_distance.pyx":89 * distances[row1, row2] = d * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -3187,7 +3185,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":89 + /* "Orange/distance/_distance.pyx":88 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3196,7 +3194,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":91 + /* "Orange/distance/_distance.pyx":90 * if not two_tables: * _lower_to_symmetric(distances) * return np.sqrt(distances) # <<<<<<<<<<<<<< @@ -3204,12 +3202,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_12 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { @@ -3222,17 +3220,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU } } if (!__pyx_t_12) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_46); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_46, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_46, 0+1, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0; } @@ -3241,7 +3239,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":34 + /* "Orange/distance/_distance.pyx":33 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -3282,7 +3280,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":94 +/* "Orange/distance/_distance.pyx":93 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -3320,11 +3318,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 93, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 94, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 93, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3337,13 +3335,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 93, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 93, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -3418,56 +3416,56 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 93, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":96 + /* "Orange/distance/_distance.pyx":95 * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:] vars = fit_params["vars"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":97 + /* "Orange/distance/_distance.pyx":96 * cdef: * double [:] means = fit_params["means"] * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 97, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":98 + /* "Orange/distance/_distance.pyx":97 * double [:] means = fit_params["means"] * double [:] vars = fit_params["vars"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_3; - /* "Orange/distance/_distance.pyx":104 + /* "Orange/distance/_distance.pyx":103 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -3479,23 +3477,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_v_n_rows = __pyx_t_4; __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":105 + /* "Orange/distance/_distance.pyx":104 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -3503,27 +3501,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 105, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 105, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":106 + /* "Orange/distance/_distance.pyx":105 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -3537,7 +3535,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":107 + /* "Orange/distance/_distance.pyx":106 * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -3548,7 +3546,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":108 + /* "Orange/distance/_distance.pyx":107 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -3559,7 +3557,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":109 + /* "Orange/distance/_distance.pyx":108 * for col1 in range(n_cols): * for col2 in range(col1): * d = 0 # <<<<<<<<<<<<<< @@ -3568,7 +3566,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":110 + /* "Orange/distance/_distance.pyx":109 * for col2 in range(col1): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -3579,7 +3577,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":111 + /* "Orange/distance/_distance.pyx":110 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -3595,7 +3593,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":112 + /* "Orange/distance/_distance.pyx":111 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -3605,7 +3603,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (__pyx_v_normalize != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":113 + /* "Orange/distance/_distance.pyx":112 * val1, val2 = x[row, col1], x[row, col2] * if normalize: * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) # <<<<<<<<<<<<<< @@ -3616,7 +3614,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_24 = __pyx_v_col1; __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_23 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_24 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":114 + /* "Orange/distance/_distance.pyx":113 * if normalize: * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) # <<<<<<<<<<<<<< @@ -3627,7 +3625,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_26 = __pyx_v_col2; __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_25 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_26 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":114 * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3637,7 +3635,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":115 * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3647,7 +3645,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":117 + /* "Orange/distance/_distance.pyx":116 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -3656,7 +3654,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":115 * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3666,7 +3664,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":118 * d += 1 * else: * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3678,7 +3676,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L14:; - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":114 * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3688,7 +3686,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":120 + /* "Orange/distance/_distance.pyx":119 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3698,7 +3696,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":121 + /* "Orange/distance/_distance.pyx":120 * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3707,7 +3705,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":120 + /* "Orange/distance/_distance.pyx":119 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3717,7 +3715,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":123 + /* "Orange/distance/_distance.pyx":122 * d += val1 ** 2 + 0.5 * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3729,7 +3727,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":112 + /* "Orange/distance/_distance.pyx":111 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -3739,7 +3737,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":124 * d += (val1 - val2) ** 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3750,7 +3748,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":126 + /* "Orange/distance/_distance.pyx":125 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3760,7 +3758,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":127 + /* "Orange/distance/_distance.pyx":126 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -3770,7 +3768,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_27 = __pyx_v_col1; __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":128 + /* "Orange/distance/_distance.pyx":127 * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< @@ -3780,7 +3778,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":127 + /* "Orange/distance/_distance.pyx":126 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -3789,7 +3787,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_27 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_28 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_29 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":126 + /* "Orange/distance/_distance.pyx":125 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3799,7 +3797,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":130 + /* "Orange/distance/_distance.pyx":129 * + (means[col1] - means[col2]) ** 2 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< @@ -3813,7 +3811,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } __pyx_L16:; - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":124 * d += (val1 - val2) ** 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3823,7 +3821,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":131 + /* "Orange/distance/_distance.pyx":130 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3833,7 +3831,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":132 + /* "Orange/distance/_distance.pyx":131 * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< @@ -3844,7 +3842,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_34 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":131 + /* "Orange/distance/_distance.pyx":130 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3854,7 +3852,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":134 + /* "Orange/distance/_distance.pyx":133 * d += (val1 - means[col2]) ** 2 + vars[col2] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3869,7 +3867,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_L12:; } - /* "Orange/distance/_distance.pyx":135 + /* "Orange/distance/_distance.pyx":134 * else: * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -3886,7 +3884,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":106 + /* "Orange/distance/_distance.pyx":105 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -3904,7 +3902,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":136 + /* "Orange/distance/_distance.pyx":135 * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d * return np.sqrt(distances) # <<<<<<<<<<<<<< @@ -3912,12 +3910,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { @@ -3930,17 +3928,17 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_39); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_39, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_39, 0+1, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0; } @@ -3949,7 +3947,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":93 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -3986,7 +3984,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":139 +/* "Orange/distance/_distance.pyx":138 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -4028,21 +4026,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 139, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 138, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 139, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 138, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 139, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 138, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 139, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 138, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -4054,19 +4052,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 139, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 138, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 139, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 140, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 139, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -4158,93 +4156,93 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 139, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 139, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":144 + /* "Orange/distance/_distance.pyx":143 * fit_params): * cdef: * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 144, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_medians = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":145 + /* "Orange/distance/_distance.pyx":144 * cdef: * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 145, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mads = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":146 + /* "Orange/distance/_distance.pyx":145 * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 146, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":147 + /* "Orange/distance/_distance.pyx":146 * double [:] mads = fit_params["mads"] * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 147, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":148 + /* "Orange/distance/_distance.pyx":147 * double [:, :] dist_missing = fit_params["dist_missing"] * double [:] dist_missing2 = fit_params["dist_missing2"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_4; - /* "Orange/distance/_distance.pyx":155 + /* "Orange/distance/_distance.pyx":154 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -4256,7 +4254,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_v_n_rows1 = __pyx_t_5; __pyx_v_n_cols = __pyx_t_6; - /* "Orange/distance/_distance.pyx":156 + /* "Orange/distance/_distance.pyx":155 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -4265,7 +4263,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":157 + /* "Orange/distance/_distance.pyx":156 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< @@ -4276,35 +4274,35 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":158 + /* "Orange/distance/_distance.pyx":157 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< * * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); } @@ -4312,7 +4310,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":157 + /* "Orange/distance/_distance.pyx":156 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< @@ -4321,28 +4319,28 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 157, __pyx_L1_error) + __PYX_ERR(0, 156, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":160 + /* "Orange/distance/_distance.pyx":159 * == len(dist_missing) == len(dist_missing2) * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); @@ -4350,27 +4348,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); __pyx_t_1 = 0; __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 160, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 160, __pyx_L1_error) + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_3; __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":161 + /* "Orange/distance/_distance.pyx":160 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -4381,7 +4379,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":162 + /* "Orange/distance/_distance.pyx":161 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -4396,7 +4394,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_row2 = __pyx_t_18; - /* "Orange/distance/_distance.pyx":163 + /* "Orange/distance/_distance.pyx":162 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< @@ -4405,7 +4403,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":164 + /* "Orange/distance/_distance.pyx":163 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -4416,7 +4414,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":165 + /* "Orange/distance/_distance.pyx":164 * d = 0 * for col in range(n_cols): * if mads[col] == -2: # <<<<<<<<<<<<<< @@ -4427,7 +4425,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":166 + /* "Orange/distance/_distance.pyx":165 * for col in range(n_cols): * if mads[col] == -2: * continue # <<<<<<<<<<<<<< @@ -4436,7 +4434,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ goto __pyx_L7_continue; - /* "Orange/distance/_distance.pyx":165 + /* "Orange/distance/_distance.pyx":164 * d = 0 * for col in range(n_cols): * if mads[col] == -2: # <<<<<<<<<<<<<< @@ -4445,7 +4443,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ } - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":167 * continue * * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -4461,7 +4459,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_v_val1 = __pyx_t_24; __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":169 + /* "Orange/distance/_distance.pyx":168 * * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4479,7 +4477,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_L11_bool_binop_done:; if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":170 + /* "Orange/distance/_distance.pyx":169 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -4489,7 +4487,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_29 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":169 + /* "Orange/distance/_distance.pyx":168 * * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4499,7 +4497,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":171 + /* "Orange/distance/_distance.pyx":170 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif mads[col] == -1: # <<<<<<<<<<<<<< @@ -4510,7 +4508,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":172 + /* "Orange/distance/_distance.pyx":171 * d += dist_missing2[col] * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< @@ -4520,7 +4518,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_v_ival1 = ((int)__pyx_v_val1); __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":173 + /* "Orange/distance/_distance.pyx":172 * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4530,7 +4528,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":174 + /* "Orange/distance/_distance.pyx":173 * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< @@ -4541,7 +4539,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_32 = __pyx_v_ival2; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":173 + /* "Orange/distance/_distance.pyx":172 * elif mads[col] == -1: * ival1, ival2 = int(val1), int(val2) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4551,7 +4549,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":175 + /* "Orange/distance/_distance.pyx":174 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4561,7 +4559,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":176 + /* "Orange/distance/_distance.pyx":175 * d += dist_missing[col, ival2] * elif npy_isnan(val2): * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< @@ -4572,7 +4570,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_34 = __pyx_v_ival1; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":175 + /* "Orange/distance/_distance.pyx":174 * if npy_isnan(val1): * d += dist_missing[col, ival2] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4582,7 +4580,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":177 + /* "Orange/distance/_distance.pyx":176 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -4592,7 +4590,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":178 + /* "Orange/distance/_distance.pyx":177 * d += dist_missing[col, ival1] * elif ival1 != ival2: * d += 1 # <<<<<<<<<<<<<< @@ -4601,7 +4599,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":177 + /* "Orange/distance/_distance.pyx":176 * elif npy_isnan(val2): * d += dist_missing[col, ival1] * elif ival1 != ival2: # <<<<<<<<<<<<<< @@ -4611,7 +4609,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":171 + /* "Orange/distance/_distance.pyx":170 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif mads[col] == -1: # <<<<<<<<<<<<<< @@ -4621,7 +4619,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":179 + /* "Orange/distance/_distance.pyx":178 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -4631,7 +4629,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (__pyx_v_normalize != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":180 + /* "Orange/distance/_distance.pyx":179 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4641,7 +4639,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":181 + /* "Orange/distance/_distance.pyx":180 * elif normalize: * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -4652,7 +4650,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_36 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":180 + /* "Orange/distance/_distance.pyx":179 * d += 1 * elif normalize: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4662,7 +4660,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":182 + /* "Orange/distance/_distance.pyx":181 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4672,7 +4670,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":183 + /* "Orange/distance/_distance.pyx":182 * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< @@ -4683,7 +4681,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_38 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":182 + /* "Orange/distance/_distance.pyx":181 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4693,7 +4691,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":185 + /* "Orange/distance/_distance.pyx":184 * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 * else: * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< @@ -4706,7 +4704,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } __pyx_L14:; - /* "Orange/distance/_distance.pyx":179 + /* "Orange/distance/_distance.pyx":178 * elif ival1 != ival2: * d += 1 * elif normalize: # <<<<<<<<<<<<<< @@ -4716,7 +4714,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":187 + /* "Orange/distance/_distance.pyx":186 * d += fabs(val1 - val2) / mads[col] / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4727,7 +4725,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":187 * else: * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -4738,7 +4736,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_41 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":187 + /* "Orange/distance/_distance.pyx":186 * d += fabs(val1 - val2) / mads[col] / 2 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4748,7 +4746,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":189 + /* "Orange/distance/_distance.pyx":188 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4758,7 +4756,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":190 + /* "Orange/distance/_distance.pyx":189 * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -4769,7 +4767,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_43 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":189 + /* "Orange/distance/_distance.pyx":188 * if npy_isnan(val1): * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4779,7 +4777,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":192 + /* "Orange/distance/_distance.pyx":191 * d += fabs(val1 - medians[col]) + mads[col] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -4795,7 +4793,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_L7_continue:; } - /* "Orange/distance/_distance.pyx":194 + /* "Orange/distance/_distance.pyx":193 * d += fabs(val1 - val2) * * distances[row1, row2] = d # <<<<<<<<<<<<<< @@ -4808,7 +4806,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":196 + /* "Orange/distance/_distance.pyx":195 * distances[row1, row2] = d * * if not two_tables: # <<<<<<<<<<<<<< @@ -4818,7 +4816,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":197 + /* "Orange/distance/_distance.pyx":196 * * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -4827,7 +4825,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":196 + /* "Orange/distance/_distance.pyx":195 * distances[row1, row2] = d * * if not two_tables: # <<<<<<<<<<<<<< @@ -4836,7 +4834,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ } - /* "Orange/distance/_distance.pyx":198 + /* "Orange/distance/_distance.pyx":197 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -4844,13 +4842,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":139 + /* "Orange/distance/_distance.pyx":138 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -4890,7 +4888,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":201 +/* "Orange/distance/_distance.pyx":200 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -4928,11 +4926,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 201, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 200, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 201, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 200, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4945,13 +4943,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 201, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 200, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -5025,56 +5023,56 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 201, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 200, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":203 + /* "Orange/distance/_distance.pyx":202 * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_medians = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":204 + /* "Orange/distance/_distance.pyx":203 * cdef: * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 204, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mads = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":205 + /* "Orange/distance/_distance.pyx":204 * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_3; - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":210 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -5086,23 +5084,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_v_n_rows = __pyx_t_4; __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":212 + /* "Orange/distance/_distance.pyx":211 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -5110,27 +5108,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 212, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 212, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":212 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -5141,7 +5139,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":214 + /* "Orange/distance/_distance.pyx":213 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -5152,7 +5150,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":215 + /* "Orange/distance/_distance.pyx":214 * for col1 in range(n_cols): * for col2 in range(col1): * d = 0 # <<<<<<<<<<<<<< @@ -5161,7 +5159,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":216 + /* "Orange/distance/_distance.pyx":215 * for col2 in range(col1): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -5172,7 +5170,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":217 + /* "Orange/distance/_distance.pyx":216 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -5188,7 +5186,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":218 + /* "Orange/distance/_distance.pyx":217 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -5198,7 +5196,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (__pyx_v_normalize != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":219 + /* "Orange/distance/_distance.pyx":218 * val1, val2 = x[row, col1], x[row, col2] * if normalize: * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< @@ -5209,7 +5207,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_24 = __pyx_v_col1; __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":220 + /* "Orange/distance/_distance.pyx":219 * if normalize: * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< @@ -5220,7 +5218,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_26 = __pyx_v_col2; __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":221 + /* "Orange/distance/_distance.pyx":220 * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5230,7 +5228,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":222 + /* "Orange/distance/_distance.pyx":221 * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5240,7 +5238,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":223 + /* "Orange/distance/_distance.pyx":222 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -5249,7 +5247,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":222 + /* "Orange/distance/_distance.pyx":221 * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5259,7 +5257,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":225 + /* "Orange/distance/_distance.pyx":224 * d += 1 * else: * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< @@ -5271,7 +5269,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L11:; - /* "Orange/distance/_distance.pyx":221 + /* "Orange/distance/_distance.pyx":220 * val1 = (val1 - medians[col1]) / (2 * mads[col1]) * val2 = (val2 - medians[col2]) / (2 * mads[col2]) * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5281,7 +5279,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":226 + /* "Orange/distance/_distance.pyx":225 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5291,7 +5289,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":227 + /* "Orange/distance/_distance.pyx":226 * d += fabs(val2) + 0.5 * elif npy_isnan(val2): * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< @@ -5300,7 +5298,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":226 + /* "Orange/distance/_distance.pyx":225 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5310,7 +5308,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":229 + /* "Orange/distance/_distance.pyx":228 * d += fabs(val1) + 0.5 * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -5322,7 +5320,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L10:; - /* "Orange/distance/_distance.pyx":218 + /* "Orange/distance/_distance.pyx":217 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if normalize: # <<<<<<<<<<<<<< @@ -5332,7 +5330,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":230 * d += fabs(val1 - val2) * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5343,7 +5341,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":231 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5353,7 +5351,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":233 + /* "Orange/distance/_distance.pyx":232 * if npy_isnan(val1): * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -5363,7 +5361,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_27 = __pyx_v_col1; __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":234 + /* "Orange/distance/_distance.pyx":233 * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< @@ -5373,7 +5371,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":233 + /* "Orange/distance/_distance.pyx":232 * if npy_isnan(val1): * if npy_isnan(val2): * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -5382,7 +5380,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN */ __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":231 * else: * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5392,7 +5390,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":235 * + fabs(medians[col1] - medians[col2]) * else: * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< @@ -5406,7 +5404,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } __pyx_L13:; - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":230 * d += fabs(val1 - val2) * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5416,7 +5414,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":237 + /* "Orange/distance/_distance.pyx":236 * else: * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5426,7 +5424,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":238 + /* "Orange/distance/_distance.pyx":237 * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< @@ -5437,7 +5435,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":237 + /* "Orange/distance/_distance.pyx":236 * else: * d += fabs(val2 - medians[col1]) + mads[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5447,7 +5445,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":240 + /* "Orange/distance/_distance.pyx":239 * d += fabs(val1 - medians[col2]) + mads[col2] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -5462,7 +5460,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_L9:; } - /* "Orange/distance/_distance.pyx":241 + /* "Orange/distance/_distance.pyx":240 * else: * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -5478,7 +5476,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":242 + /* "Orange/distance/_distance.pyx":241 * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< @@ -5486,13 +5484,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":201 + /* "Orange/distance/_distance.pyx":200 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -5528,7 +5526,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":245 +/* "Orange/distance/_distance.pyx":244 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -5544,7 +5542,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__py PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 245, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 244, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ @@ -5577,11 +5575,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 245, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 244, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":250 + /* "Orange/distance/_distance.pyx":249 * double val * * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< @@ -5591,18 +5589,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_v_nonzeros = 0; __pyx_v_nonnans = 0; - /* "Orange/distance/_distance.pyx":251 + /* "Orange/distance/_distance.pyx":250 * * nonzeros = nonnans = 0 * for row in range(len(x)): # <<<<<<<<<<<<<< * val = x[row] * if not npy_isnan(val): */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 250, __pyx_L1_error) for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":252 + /* "Orange/distance/_distance.pyx":251 * nonzeros = nonnans = 0 * for row in range(len(x)): * val = x[row] # <<<<<<<<<<<<<< @@ -5612,7 +5610,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_3 = __pyx_v_row; __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - /* "Orange/distance/_distance.pyx":253 + /* "Orange/distance/_distance.pyx":252 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -5622,7 +5620,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":254 + /* "Orange/distance/_distance.pyx":253 * val = x[row] * if not npy_isnan(val): * nonnans += 1 # <<<<<<<<<<<<<< @@ -5631,7 +5629,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ __pyx_v_nonnans = (__pyx_v_nonnans + 1); - /* "Orange/distance/_distance.pyx":255 + /* "Orange/distance/_distance.pyx":254 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -5641,7 +5639,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":256 + /* "Orange/distance/_distance.pyx":255 * nonnans += 1 * if val != 0: * nonzeros += 1 # <<<<<<<<<<<<<< @@ -5650,7 +5648,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - /* "Orange/distance/_distance.pyx":255 + /* "Orange/distance/_distance.pyx":254 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -5659,7 +5657,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ } - /* "Orange/distance/_distance.pyx":253 + /* "Orange/distance/_distance.pyx":252 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -5669,7 +5667,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED } } - /* "Orange/distance/_distance.pyx":257 + /* "Orange/distance/_distance.pyx":256 * if val != 0: * nonzeros += 1 * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< @@ -5677,13 +5675,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":245 + /* "Orange/distance/_distance.pyx":244 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -5711,7 +5709,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED return __pyx_r; } -/* "Orange/distance/_distance.pyx":260 +/* "Orange/distance/_distance.pyx":259 * * * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -5752,7 +5750,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli Py_ssize_t __pyx_t_21; __Pyx_RefNannySetupContext("_abs_rows", 0); - /* "Orange/distance/_distance.pyx":266 + /* "Orange/distance/_distance.pyx":265 * int row, col, n_rows, n_cols * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -5764,19 +5762,19 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":267 + /* "Orange/distance/_distance.pyx":266 * * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) # <<<<<<<<<<<<<< * with nogil: * for row in range(n_rows): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { @@ -5789,29 +5787,29 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 267, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":267 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) * with nogil: # <<<<<<<<<<<<<< @@ -5825,7 +5823,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":269 + /* "Orange/distance/_distance.pyx":268 * abss = np.empty(n_rows) * with nogil: * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -5836,7 +5834,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_row = __pyx_t_10; - /* "Orange/distance/_distance.pyx":270 + /* "Orange/distance/_distance.pyx":269 * with nogil: * for row in range(n_rows): * d = 0 # <<<<<<<<<<<<<< @@ -5845,7 +5843,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":271 + /* "Orange/distance/_distance.pyx":270 * for row in range(n_rows): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -5856,7 +5854,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_col = __pyx_t_12; - /* "Orange/distance/_distance.pyx":272 + /* "Orange/distance/_distance.pyx":271 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -5867,7 +5865,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":273 + /* "Orange/distance/_distance.pyx":272 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -5876,7 +5874,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ goto __pyx_L8_continue; - /* "Orange/distance/_distance.pyx":272 + /* "Orange/distance/_distance.pyx":271 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -5885,7 +5883,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ } - /* "Orange/distance/_distance.pyx":274 + /* "Orange/distance/_distance.pyx":273 * if vars[col] == -2: * continue * val = x[row, col] # <<<<<<<<<<<<<< @@ -5896,7 +5894,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_16 = __pyx_v_col; __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":275 + /* "Orange/distance/_distance.pyx":274 * continue * val = x[row, col] * if vars[col] == -1: # <<<<<<<<<<<<<< @@ -5907,7 +5905,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":276 + /* "Orange/distance/_distance.pyx":275 * val = x[row, col] * if vars[col] == -1: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5917,7 +5915,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":276 * if vars[col] == -1: * if npy_isnan(val): * d += means[col] # <<<<<<<<<<<<<< @@ -5927,7 +5925,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_18 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":276 + /* "Orange/distance/_distance.pyx":275 * val = x[row, col] * if vars[col] == -1: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5937,7 +5935,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":277 * if npy_isnan(val): * d += means[col] * elif val != 0: # <<<<<<<<<<<<<< @@ -5947,7 +5945,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":279 + /* "Orange/distance/_distance.pyx":278 * d += means[col] * elif val != 0: * d += 1 # <<<<<<<<<<<<<< @@ -5956,7 +5954,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":277 * if npy_isnan(val): * d += means[col] * elif val != 0: # <<<<<<<<<<<<<< @@ -5966,7 +5964,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } __pyx_L12:; - /* "Orange/distance/_distance.pyx":275 + /* "Orange/distance/_distance.pyx":274 * continue * val = x[row, col] * if vars[col] == -1: # <<<<<<<<<<<<<< @@ -5976,7 +5974,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":281 + /* "Orange/distance/_distance.pyx":280 * d += 1 * else: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5987,7 +5985,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":282 + /* "Orange/distance/_distance.pyx":281 * else: * if npy_isnan(val): * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -5998,7 +5996,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_20 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":281 + /* "Orange/distance/_distance.pyx":280 * d += 1 * else: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -6008,7 +6006,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":284 + /* "Orange/distance/_distance.pyx":283 * d += means[col] ** 2 + vars[col] * else: * d += val ** 2 # <<<<<<<<<<<<<< @@ -6024,7 +6022,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_L8_continue:; } - /* "Orange/distance/_distance.pyx":285 + /* "Orange/distance/_distance.pyx":284 * else: * d += val ** 2 * abss[row] = sqrt(d) # <<<<<<<<<<<<<< @@ -6036,7 +6034,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":267 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) * with nogil: # <<<<<<<<<<<<<< @@ -6054,7 +6052,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":286 + /* "Orange/distance/_distance.pyx":285 * d += val ** 2 * abss[row] = sqrt(d) * return abss # <<<<<<<<<<<<<< @@ -6062,13 +6060,13 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":260 + /* "Orange/distance/_distance.pyx":259 * * * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -6093,7 +6091,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli return __pyx_r; } -/* "Orange/distance/_distance.pyx":289 +/* "Orange/distance/_distance.pyx":288 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -6135,21 +6133,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *_ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 289, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 288, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 289, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 288, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 289, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 288, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 289, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6161,19 +6159,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *_ } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 289, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 289, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 290, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 288, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 289, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -6254,64 +6252,64 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 289, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 288, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 289, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 288, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":294 + /* "Orange/distance/_distance.pyx":293 * fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 294, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":295 + /* "Orange/distance/_distance.pyx":294 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":296 + /* "Orange/distance/_distance.pyx":295 * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 296, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":303 + /* "Orange/distance/_distance.pyx":302 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -6323,7 +6321,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":304 + /* "Orange/distance/_distance.pyx":303 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -6332,7 +6330,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":305 + /* "Orange/distance/_distance.pyx":304 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -6343,36 +6341,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":306 + /* "Orange/distance/_distance.pyx":305 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing2) # <<<<<<<<<<<<<< * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); } } } - /* "Orange/distance/_distance.pyx":305 + /* "Orange/distance/_distance.pyx":304 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -6381,12 +6379,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 305, __pyx_L1_error) + __PYX_ERR(0, 304, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":307 + /* "Orange/distance/_distance.pyx":306 * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing2) * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< @@ -6394,18 +6392,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 307, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 306, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_abs1 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":308 + /* "Orange/distance/_distance.pyx":307 * == len(dist_missing2) * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< @@ -6414,21 +6412,21 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if ((__pyx_v_two_tables != 0)) { __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL; } else { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_10; __pyx_t_10.memview = NULL; @@ -6438,23 +6436,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":309 + /* "Orange/distance/_distance.pyx":308 * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * * with nogil: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); @@ -6462,27 +6460,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); __pyx_t_1 = 0; __pyx_t_12 = 0; - __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = 0; - __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 309, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":311 + /* "Orange/distance/_distance.pyx":310 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -6496,7 +6494,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":312 + /* "Orange/distance/_distance.pyx":311 * * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -6507,7 +6505,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row1 = __pyx_t_15; - /* "Orange/distance/_distance.pyx":313 + /* "Orange/distance/_distance.pyx":312 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -6522,7 +6520,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_row2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":313 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< @@ -6531,7 +6529,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":315 + /* "Orange/distance/_distance.pyx":314 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -6542,7 +6540,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_col = __pyx_t_19; - /* "Orange/distance/_distance.pyx":316 + /* "Orange/distance/_distance.pyx":315 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -6553,7 +6551,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":317 + /* "Orange/distance/_distance.pyx":316 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -6562,7 +6560,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":316 + /* "Orange/distance/_distance.pyx":315 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -6571,7 +6569,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":318 + /* "Orange/distance/_distance.pyx":317 * if vars[col] == -2: * continue * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -6587,7 +6585,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_v_val1 = __pyx_t_23; __pyx_v_val2 = __pyx_t_26; - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":318 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6605,7 +6603,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L14_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":320 + /* "Orange/distance/_distance.pyx":319 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -6615,7 +6613,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_28 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":318 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6625,7 +6623,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":321 + /* "Orange/distance/_distance.pyx":320 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -6636,7 +6634,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":322 + /* "Orange/distance/_distance.pyx":321 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6656,7 +6654,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } __pyx_L18_next_or:; - /* "Orange/distance/_distance.pyx":323 + /* "Orange/distance/_distance.pyx":322 * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< @@ -6673,7 +6671,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = __pyx_t_27; __pyx_L17_bool_binop_done:; - /* "Orange/distance/_distance.pyx":322 + /* "Orange/distance/_distance.pyx":321 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6682,7 +6680,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":324 + /* "Orange/distance/_distance.pyx":323 * if npy_isnan(val1) and val2 != 0 \ * or npy_isnan(val2) and val1 != 0: * d += means[col] # <<<<<<<<<<<<<< @@ -6692,7 +6690,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_30 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":322 + /* "Orange/distance/_distance.pyx":321 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6702,7 +6700,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":325 + /* "Orange/distance/_distance.pyx":324 * or npy_isnan(val2) and val1 != 0: * d += means[col] * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -6720,7 +6718,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L21_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":326 + /* "Orange/distance/_distance.pyx":325 * d += means[col] * elif val1 != 0 and val2 != 0: * d += 1 # <<<<<<<<<<<<<< @@ -6729,7 +6727,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":325 + /* "Orange/distance/_distance.pyx":324 * or npy_isnan(val2) and val1 != 0: * d += means[col] * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -6739,7 +6737,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } __pyx_L16:; - /* "Orange/distance/_distance.pyx":321 + /* "Orange/distance/_distance.pyx":320 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -6749,7 +6747,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":328 + /* "Orange/distance/_distance.pyx":327 * d += 1 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6760,7 +6758,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":328 * else: * if npy_isnan(val1): * d += val2 * means[col] # <<<<<<<<<<<<<< @@ -6770,7 +6768,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_31 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":328 + /* "Orange/distance/_distance.pyx":327 * d += 1 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6780,7 +6778,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":330 + /* "Orange/distance/_distance.pyx":329 * if npy_isnan(val1): * d += val2 * means[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6790,7 +6788,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":331 + /* "Orange/distance/_distance.pyx":330 * d += val2 * means[col] * elif npy_isnan(val2): * d += val1 * means[col] # <<<<<<<<<<<<<< @@ -6800,7 +6798,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_32 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":330 + /* "Orange/distance/_distance.pyx":329 * if npy_isnan(val1): * d += val2 * means[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6810,11 +6808,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":332 * d += val1 * means[col] * else: * d += val1 * val2 # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] * if not two_tables: */ /*else*/ { @@ -6826,10 +6824,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L10_continue:; } - /* "Orange/distance/_distance.pyx":334 + /* "Orange/distance/_distance.pyx":333 * else: * d += val1 * val2 - * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< * if not two_tables: * _lower_to_symmetric(distances) */ @@ -6837,12 +6835,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_34 = __pyx_v_row2; __pyx_t_35 = __pyx_v_row1; __pyx_t_36 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = (1.0 - cos(((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) )))))); + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); } } } - /* "Orange/distance/_distance.pyx":311 + /* "Orange/distance/_distance.pyx":310 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -6860,9 +6858,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":335 + /* "Orange/distance/_distance.pyx":334 * d += val1 * val2 - * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances @@ -6870,8 +6868,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":336 - * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + /* "Orange/distance/_distance.pyx":335 + * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances @@ -6879,16 +6877,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":335 + /* "Orange/distance/_distance.pyx":334 * d += val1 * val2 - * distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":337 + /* "Orange/distance/_distance.pyx":336 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -6896,13 +6894,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":289 + /* "Orange/distance/_distance.pyx":288 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -6944,7 +6942,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":340 +/* "Orange/distance/_distance.pyx":339 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -6975,16 +6973,17 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli int __pyx_t_10; Py_ssize_t __pyx_t_11; int __pyx_t_12; - int __pyx_t_13; + Py_ssize_t __pyx_t_13; int __pyx_t_14; - Py_ssize_t __pyx_t_15; + int __pyx_t_15; Py_ssize_t __pyx_t_16; Py_ssize_t __pyx_t_17; Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; __Pyx_RefNannySetupContext("_abs_cols", 0); - /* "Orange/distance/_distance.pyx":346 + /* "Orange/distance/_distance.pyx":345 * int row, col, n_rows, n_cols, nan_cont * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -6996,19 +6995,19 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":347 + /* "Orange/distance/_distance.pyx":346 * * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) # <<<<<<<<<<<<<< * with nogil: * for col in range(n_cols): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { @@ -7021,29 +7020,29 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 347, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":348 + /* "Orange/distance/_distance.pyx":347 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7057,48 +7056,58 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":348 * abss = np.empty(n_cols) * with nogil: * for col in range(n_cols): # <<<<<<<<<<<<<< * if vars[col] == -2: - * continue + * abss[col] = 1 */ __pyx_t_9 = __pyx_v_n_cols; for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col = __pyx_t_10; - /* "Orange/distance/_distance.pyx":350 + /* "Orange/distance/_distance.pyx":349 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< + * abss[col] = 1 * continue - * d = 0 */ __pyx_t_11 = __pyx_v_col; __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":351 + /* "Orange/distance/_distance.pyx":350 * for col in range(n_cols): * if vars[col] == -2: + * abss[col] = 1 # <<<<<<<<<<<<<< + * continue + * d = 0 + */ + __pyx_t_13 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; + + /* "Orange/distance/_distance.pyx":351 + * if vars[col] == -2: + * abss[col] = 1 * continue # <<<<<<<<<<<<<< * d = 0 * nan_cont = 0 */ goto __pyx_L6_continue; - /* "Orange/distance/_distance.pyx":350 + /* "Orange/distance/_distance.pyx":349 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< + * abss[col] = 1 * continue - * d = 0 */ } /* "Orange/distance/_distance.pyx":352 - * if vars[col] == -2: + * abss[col] = 1 * continue * d = 0 # <<<<<<<<<<<<<< * nan_cont = 0 @@ -7122,9 +7131,9 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * val = x[row, col] * if npy_isnan(val): */ - __pyx_t_13 = __pyx_v_n_rows; - for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { - __pyx_v_row = __pyx_t_14; + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; /* "Orange/distance/_distance.pyx":355 * nan_cont = 0 @@ -7133,9 +7142,9 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * if npy_isnan(val): * nan_cont += 1 */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col; - __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col; + __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); /* "Orange/distance/_distance.pyx":356 * for row in range(n_rows): @@ -7186,9 +7195,9 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * abss[col] = sqrt(d) * return abss */ - __pyx_t_17 = __pyx_v_col; __pyx_t_18 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_17 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) )))))); + __pyx_t_19 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); /* "Orange/distance/_distance.pyx":361 * d += val ** 2 @@ -7197,13 +7206,13 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * return abss * */ - __pyx_t_19 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_19 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); + __pyx_t_20 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_20 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); __pyx_L6_continue:; } } - /* "Orange/distance/_distance.pyx":348 + /* "Orange/distance/_distance.pyx":347 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7235,7 +7244,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":339 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -7485,7 +7494,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< * distances = np.zeros((n_cols, n_cols), dtype=float) - * + * for col1 in range(n_cols): */ __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 379, __pyx_L1_error) @@ -7503,8 +7512,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< - * * for col1 in range(n_cols): + * if vars[col1] == -2: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -7558,9 +7567,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":381 + * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) - * * for col1 in range(n_cols): # <<<<<<<<<<<<<< * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 @@ -7569,8 +7578,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { __pyx_v_col1 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":383 - * + /* "Orange/distance/_distance.pyx":382 + * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< * distances[col1, :] = distances[:, col1] = 1.0 @@ -7580,16 +7589,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":384 + /* "Orange/distance/_distance.pyx":383 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); @@ -7597,11 +7606,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_slice__2); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice__2); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -7609,10 +7618,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __pyx_t_11 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":384 * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 * continue # <<<<<<<<<<<<<< @@ -7621,8 +7630,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L3_continue; - /* "Orange/distance/_distance.pyx":383 - * + /* "Orange/distance/_distance.pyx":382 + * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< * distances[col1, :] = distances[:, col1] = 1.0 @@ -7630,7 +7639,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":386 + /* "Orange/distance/_distance.pyx":385 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -7644,7 +7653,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":386 * continue * with nogil: * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -7655,7 +7664,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":388 + /* "Orange/distance/_distance.pyx":387 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7666,7 +7675,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":389 + /* "Orange/distance/_distance.pyx":388 * for col2 in range(col1): * if vars[col2] == -2: * continue # <<<<<<<<<<<<<< @@ -7675,7 +7684,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L11_continue; - /* "Orange/distance/_distance.pyx":388 + /* "Orange/distance/_distance.pyx":387 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7684,7 +7693,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":390 + /* "Orange/distance/_distance.pyx":389 * if vars[col2] == -2: * continue * d = 0 # <<<<<<<<<<<<<< @@ -7693,7 +7702,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":391 + /* "Orange/distance/_distance.pyx":390 * continue * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7704,7 +7713,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_row = __pyx_t_23; - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":391 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -7720,7 +7729,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_val1 = __pyx_t_26; __pyx_v_val2 = __pyx_t_29; - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":392 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7738,7 +7747,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L17_bool_binop_done:; if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":394 + /* "Orange/distance/_distance.pyx":393 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] # <<<<<<<<<<<<<< @@ -7749,7 +7758,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_32 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":392 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7759,7 +7768,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":395 + /* "Orange/distance/_distance.pyx":394 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7769,7 +7778,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":395 * d += means[col1] * means[col2] * elif npy_isnan(val1): * d += val2 * means[col1] # <<<<<<<<<<<<<< @@ -7779,7 +7788,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_33 = __pyx_v_col1; __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":395 + /* "Orange/distance/_distance.pyx":394 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7789,7 +7798,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":396 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7799,7 +7808,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":398 + /* "Orange/distance/_distance.pyx":397 * d += val2 * means[col1] * elif npy_isnan(val2): * d += val1 * means[col2] # <<<<<<<<<<<<<< @@ -7809,7 +7818,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":396 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7819,12 +7828,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":400 + /* "Orange/distance/_distance.pyx":399 * d += val1 * means[col2] * else: * d += val1 * val2 # <<<<<<<<<<<<<< * distances[col1, col2] = distances[col2, col1] = \ - * 1 - cos(d / abss[col1] / abss[col2]) + * 1 - d / abss[col1] / abss[col2] */ /*else*/ { __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); @@ -7832,22 +7841,22 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L16:; } - /* "Orange/distance/_distance.pyx":402 + /* "Orange/distance/_distance.pyx":401 * d += val1 * val2 * distances[col1, col2] = distances[col2, col1] = \ - * 1 - cos(d / abss[col1] / abss[col2]) # <<<<<<<<<<<<<< + * 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< * return distances * */ __pyx_t_35 = __pyx_v_col1; __pyx_t_36 = __pyx_v_col2; - __pyx_t_37 = (1.0 - cos(((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) )))))); + __pyx_t_37 = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":401 + /* "Orange/distance/_distance.pyx":400 * else: * d += val1 * val2 * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< - * 1 - cos(d / abss[col1] / abss[col2]) + * 1 - d / abss[col1] / abss[col2] * return distances */ __pyx_t_38 = __pyx_v_col1; @@ -7860,7 +7869,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":386 + /* "Orange/distance/_distance.pyx":385 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -7880,9 +7889,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L3_continue:; } - /* "Orange/distance/_distance.pyx":403 + /* "Orange/distance/_distance.pyx":402 * distances[col1, col2] = distances[col2, col1] = \ - * 1 - cos(d / abss[col1] / abss[col2]) + * 1 - d / abss[col1] / abss[col2] * return distances # <<<<<<<<<<<<<< * * @@ -7931,7 +7940,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":406 +/* "Orange/distance/_distance.pyx":405 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -7973,21 +7982,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 406, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 405, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 406, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 405, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 406, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 405, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 406, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 405, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -7999,19 +8008,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 408, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 405, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 406, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 407, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 405, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 406, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -8083,32 +8092,32 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 406, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 405, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 406, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 405, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":411 + /* "Orange/distance/_distance.pyx":410 * fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 410, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 411, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 410, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":418 + /* "Orange/distance/_distance.pyx":417 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -8120,7 +8129,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":419 + /* "Orange/distance/_distance.pyx":418 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -8129,12 +8138,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":420 + /* "Orange/distance/_distance.pyx":419 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< * - * distances = np.ones((n_rows1, n_rows2), dtype=float) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { @@ -8144,28 +8153,28 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 420, __pyx_L1_error) + __PYX_ERR(0, 419, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":422 + /* "Orange/distance/_distance.pyx":421 * assert n_cols == x2.shape[1] == ps.shape[0] * - * distances = np.ones((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -8173,29 +8182,29 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 422, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 422, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":423 + /* "Orange/distance/_distance.pyx":422 * - * distances = np.ones((n_rows1, n_rows2), dtype=float) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -8207,8 +8216,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":424 - * distances = np.ones((n_rows1, n_rows2), dtype=float) + /* "Orange/distance/_distance.pyx":423 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): @@ -8218,7 +8227,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_row1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":425 + /* "Orange/distance/_distance.pyx":424 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -8233,31 +8242,31 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":426 + /* "Orange/distance/_distance.pyx":425 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] */ __pyx_v_intersection = 0.0; __pyx_v_union = 0.0; - /* "Orange/distance/_distance.pyx":427 + /* "Orange/distance/_distance.pyx":426 * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x1[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): */ __pyx_t_14 = __pyx_v_n_cols; for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":428 + /* "Orange/distance/_distance.pyx":427 * intersection = union = 0 * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< * if npy_isnan(val1): * if npy_isnan(val2): */ @@ -8266,13 +8275,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); __pyx_t_19 = __pyx_v_row2; __pyx_t_20 = __pyx_v_col; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides)); __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":428 * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): * intersection += ps[col] ** 2 @@ -8280,8 +8289,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":430 - * val1, val2 = x1[row1, col], x1[row2, col] + /* "Orange/distance/_distance.pyx":429 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< * intersection += ps[col] ** 2 @@ -8290,7 +8299,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":431 + /* "Orange/distance/_distance.pyx":430 * if npy_isnan(val1): * if npy_isnan(val2): * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< @@ -8300,7 +8309,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_22 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); - /* "Orange/distance/_distance.pyx":432 + /* "Orange/distance/_distance.pyx":431 * if npy_isnan(val2): * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< @@ -8310,8 +8319,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_23 = __pyx_v_col; __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":430 - * val1, val2 = x1[row1, col], x1[row2, col] + /* "Orange/distance/_distance.pyx":429 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< * intersection += ps[col] ** 2 @@ -8320,7 +8329,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":433 + /* "Orange/distance/_distance.pyx":432 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8330,7 +8339,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":434 + /* "Orange/distance/_distance.pyx":433 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8340,7 +8349,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_24 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":435 + /* "Orange/distance/_distance.pyx":434 * elif val2 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8349,7 +8358,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":433 + /* "Orange/distance/_distance.pyx":432 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8359,7 +8368,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":436 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8372,9 +8381,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L13:; - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":428 * for col in range(n_cols): - * val1, val2 = x1[row1, col], x1[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): * intersection += ps[col] ** 2 @@ -8382,7 +8391,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":437 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8392,7 +8401,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":438 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8402,7 +8411,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":439 * elif npy_isnan(val2): * if val1 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8412,7 +8421,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_26 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":441 + /* "Orange/distance/_distance.pyx":440 * if val1 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8421,7 +8430,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":438 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8431,7 +8440,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":443 + /* "Orange/distance/_distance.pyx":442 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8444,7 +8453,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L14:; - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":437 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8454,7 +8463,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":445 + /* "Orange/distance/_distance.pyx":444 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8473,7 +8482,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L16_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":445 * else: * if val1 != 0 and val2 != 0: * intersection += 1 # <<<<<<<<<<<<<< @@ -8482,7 +8491,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":445 + /* "Orange/distance/_distance.pyx":444 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8491,7 +8500,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":446 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8509,7 +8518,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L19_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":447 * intersection += 1 * if val1 != 0 or val2 != 0: * union += 1 # <<<<<<<<<<<<<< @@ -8518,7 +8527,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":446 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8530,7 +8539,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L12:; } - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":448 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8540,7 +8549,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":450 + /* "Orange/distance/_distance.pyx":449 * union += 1 * if union != 0: * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< @@ -8551,7 +8560,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_30 = __pyx_v_row2; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":448 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8563,9 +8572,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":423 + /* "Orange/distance/_distance.pyx":422 * - * distances = np.ones((n_rows1, n_rows2), dtype=float) + * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -8581,7 +8590,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":452 + /* "Orange/distance/_distance.pyx":451 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8591,7 +8600,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":453 + /* "Orange/distance/_distance.pyx":452 * * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -8600,7 +8609,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":452 + /* "Orange/distance/_distance.pyx":451 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8609,7 +8618,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":454 + /* "Orange/distance/_distance.pyx":453 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -8617,13 +8626,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":405 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -8660,7 +8669,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":457 +/* "Orange/distance/_distance.pyx":456 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -8698,11 +8707,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 457, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 456, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 457, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 456, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -8715,13 +8724,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 457, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 456, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 457, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 456, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -8796,31 +8805,31 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 457, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 456, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":459 + /* "Orange/distance/_distance.pyx":458 * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 459, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 458, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":465 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * distances = np.ones((n_cols, n_cols), dtype=float) + * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): */ __pyx_t_3 = (__pyx_v_x->dimensions[0]); @@ -8828,23 +8837,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":466 * * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.ones((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); @@ -8852,29 +8861,29 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 467, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 467, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":468 + /* "Orange/distance/_distance.pyx":467 * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.ones((n_cols, n_cols), dtype=float) + * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< * for col2 in range(col1): * in_both = in_one = 0 @@ -8883,8 +8892,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col1 = __pyx_t_10; - /* "Orange/distance/_distance.pyx":469 - * distances = np.ones((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":468 + * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< * in_both = in_one = 0 @@ -8894,7 +8903,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_col2 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":470 + /* "Orange/distance/_distance.pyx":469 * for col1 in range(n_cols): * for col2 in range(col1): * in_both = in_one = 0 # <<<<<<<<<<<<<< @@ -8904,7 +8913,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_one = 0; - /* "Orange/distance/_distance.pyx":471 + /* "Orange/distance/_distance.pyx":470 * for col2 in range(col1): * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< @@ -8917,7 +8926,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_unk1_not2 = 0; __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":472 + /* "Orange/distance/_distance.pyx":471 * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -8928,7 +8937,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_row = __pyx_t_14; - /* "Orange/distance/_distance.pyx":473 + /* "Orange/distance/_distance.pyx":472 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -8944,7 +8953,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_val1 = __pyx_t_17; __pyx_v_val2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":474 + /* "Orange/distance/_distance.pyx":473 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8954,7 +8963,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":475 + /* "Orange/distance/_distance.pyx":474 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8964,7 +8973,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":475 * if npy_isnan(val1): * if npy_isnan(val2): * unk1_unk2 += 1 # <<<<<<<<<<<<<< @@ -8973,7 +8982,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":475 + /* "Orange/distance/_distance.pyx":474 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8983,7 +8992,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":477 + /* "Orange/distance/_distance.pyx":476 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8993,7 +9002,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":478 + /* "Orange/distance/_distance.pyx":477 * unk1_unk2 += 1 * elif val2 != 0: * unk1_in2 += 1 # <<<<<<<<<<<<<< @@ -9002,7 +9011,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "Orange/distance/_distance.pyx":477 + /* "Orange/distance/_distance.pyx":476 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -9012,7 +9021,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":480 + /* "Orange/distance/_distance.pyx":479 * unk1_in2 += 1 * else: * unk1_not2 += 1 # <<<<<<<<<<<<<< @@ -9024,7 +9033,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } __pyx_L10:; - /* "Orange/distance/_distance.pyx":474 + /* "Orange/distance/_distance.pyx":473 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -9034,7 +9043,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":480 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9044,7 +9053,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":482 + /* "Orange/distance/_distance.pyx":481 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -9054,7 +9063,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":483 + /* "Orange/distance/_distance.pyx":482 * elif npy_isnan(val2): * if val1 != 0: * in1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9063,7 +9072,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "Orange/distance/_distance.pyx":482 + /* "Orange/distance/_distance.pyx":481 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -9073,7 +9082,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":485 + /* "Orange/distance/_distance.pyx":484 * in1_unk2 += 1 * else: * not1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9085,7 +9094,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } __pyx_L11:; - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":480 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9095,7 +9104,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":487 + /* "Orange/distance/_distance.pyx":486 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -9114,7 +9123,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L13_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":488 + /* "Orange/distance/_distance.pyx":487 * else: * if val1 != 0 and val2 != 0: * in_both += 1 # <<<<<<<<<<<<<< @@ -9123,7 +9132,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + 1); - /* "Orange/distance/_distance.pyx":487 + /* "Orange/distance/_distance.pyx":486 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -9133,7 +9142,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":489 + /* "Orange/distance/_distance.pyx":488 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -9151,7 +9160,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L15_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":490 + /* "Orange/distance/_distance.pyx":489 * in_both += 1 * elif val1 != 0 or val2 != 0: * in_one += 1 # <<<<<<<<<<<<<< @@ -9160,7 +9169,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in_one = (__pyx_v_in_one + 1); - /* "Orange/distance/_distance.pyx":489 + /* "Orange/distance/_distance.pyx":488 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -9173,7 +9182,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L9:; } - /* "Orange/distance/_distance.pyx":493 + /* "Orange/distance/_distance.pyx":492 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< @@ -9182,7 +9191,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_23 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":494 + /* "Orange/distance/_distance.pyx":493 * 1 - float(in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -9191,7 +9200,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_24 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":495 + /* "Orange/distance/_distance.pyx":494 * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< @@ -9201,7 +9210,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_25 = __pyx_v_col1; __pyx_t_26 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":497 + /* "Orange/distance/_distance.pyx":496 * + ps[col1] * ps[col2] * unk1_unk2) / \ * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< @@ -9210,7 +9219,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_27 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":498 + /* "Orange/distance/_distance.pyx":497 * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< @@ -9219,7 +9228,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":499 + /* "Orange/distance/_distance.pyx":498 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< @@ -9228,7 +9237,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":492 + /* "Orange/distance/_distance.pyx":491 * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both # <<<<<<<<<<<<<< @@ -9237,7 +9246,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - /* "Orange/distance/_distance.pyx":491 + /* "Orange/distance/_distance.pyx":490 * elif val1 != 0 or val2 != 0: * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -9253,19 +9262,19 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":500 + /* "Orange/distance/_distance.pyx":499 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":456 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -23778,7 +23787,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, - {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, {&__pyx_n_s_p_nonzero, __pyx_k_p_nonzero, sizeof(__pyx_k_p_nonzero), 0, 0, 1, 1}, {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1}, @@ -23819,8 +23827,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 22, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 21, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 23, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) @@ -23837,28 +23845,28 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "Orange/distance/_distance.pyx":24 + /* "Orange/distance/_distance.pyx":23 * for col in range(dividers.shape[0]): * if dividers[col] == 0 and not x[:, col].isnan().all(): * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< * * */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "Orange/distance/_distance.pyx":384 + /* "Orange/distance/_distance.pyx":383 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); - __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -24074,77 +24082,77 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); - /* "Orange/distance/_distance.pyx":34 + /* "Orange/distance/_distance.pyx":33 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__23 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 34, __pyx_L1_error) + __pyx_tuple__23 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 34, __pyx_L1_error) + __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 33, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":93 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] means = fit_params["means"] */ - __pyx_tuple__25 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_tuple__25 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 93, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":139 + /* "Orange/distance/_distance.pyx":138 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__27 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_tuple__27 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 139, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 138, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":201 + /* "Orange/distance/_distance.pyx":200 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 201, __pyx_L1_error) + __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 201, __pyx_L1_error) + __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 200, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":245 + /* "Orange/distance/_distance.pyx":244 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31); - __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 245, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 244, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 244, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":289 + /* "Orange/distance/_distance.pyx":288 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33); - __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 289, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 288, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 288, __pyx_L1_error) /* "Orange/distance/_distance.pyx":365 * @@ -24158,29 +24166,29 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__35); __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 365, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 365, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":405 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 406, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 406, __pyx_L1_error) + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 405, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 405, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":456 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39); - __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 457, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 456, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 456, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -24406,76 +24414,76 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":34 + /* "Orange/distance/_distance.pyx":33 * * * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":93 * * * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] means = fit_params["means"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 94, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":139 + /* "Orange/distance/_distance.pyx":138 * * * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 139, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":201 + /* "Orange/distance/_distance.pyx":200 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 201, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":245 + /* "Orange/distance/_distance.pyx":244 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 245, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":289 + /* "Orange/distance/_distance.pyx":288 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 289, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":365 @@ -24490,28 +24498,28 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":405 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 406, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":456 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 457, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index 062e212e585..a573bf1ab5c 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -13,7 +13,6 @@ cdef extern from "numpy/npy_math.h": cdef extern from "math.h": double fabs(double x) nogil double sqrt(double x) nogil - double cos(double x) nogil # This function is unused, but kept here for any future use @@ -331,7 +330,7 @@ def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, d += val1 * means[col] else: d += val1 * val2 - distances[row1, row2] = 1 - cos(d / abs1[row1] / abs2[row2]) + distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] if not two_tables: _lower_to_symmetric(distances) return distances @@ -348,6 +347,7 @@ cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): with nogil: for col in range(n_cols): if vars[col] == -2: + abss[col] = 1 continue d = 0 nan_cont = 0 @@ -378,7 +378,6 @@ def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): assert n_cols == len(vars) == len(means) abss = _abs_cols(x, means, vars) distances = np.zeros((n_cols, n_cols), dtype=float) - for col1 in range(n_cols): if vars[col1] == -2: distances[col1, :] = distances[:, col1] = 1.0 @@ -399,7 +398,7 @@ def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): else: d += val1 * val2 distances[col1, col2] = distances[col2, col1] = \ - 1 - cos(d / abss[col1] / abss[col2]) + 1 - d / abss[col1] / abss[col2] return distances @@ -419,13 +418,13 @@ def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, n_rows2 = x2.shape[0] assert n_cols == x2.shape[1] == ps.shape[0] - distances = np.ones((n_rows1, n_rows2), dtype=float) + distances = np.zeros((n_rows1, n_rows2), dtype=float) with nogil: for row1 in range(n_rows1): for row2 in range(n_rows2 if two_tables else row1): intersection = union = 0 for col in range(n_cols): - val1, val2 = x1[row1, col], x1[row2, col] + val1, val2 = x1[row1, col], x2[row2, col] if npy_isnan(val1): if npy_isnan(val2): intersection += ps[col] ** 2 @@ -464,7 +463,7 @@ def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): double [:, :] distances n_rows, n_cols = x.shape[0], x.shape[1] - distances = np.ones((n_cols, n_cols), dtype=float) + distances = np.zeros((n_cols, n_cols), dtype=float) for col1 in range(n_cols): for col2 in range(col1): in_both = in_one = 0 diff --git a/Orange/distance/tests/calculation.xlsx b/Orange/distance/tests/calculation.xlsx index 47fa16221232591a5b3c0591c1bf97a1b3896ddd..8f8aa3f7df2ab210544c08d7bcabdf1bc386ed6e 100644 GIT binary patch delta 33701 zcmY(qV{o8P@GctLwryi$+Z)^VZk)W?*tTuk=EnBMww>JH|D1Dg-Bb1S)J%6**UX3M zdImib22mIVQ8$7Gw<)lo^$!XJWG5~Pb;q0*G)J!2e z3WR?c)i%hliPO#{o-8}mfBQ=PRm>_WPyAQCHrP#(!k}7;JbwRNNppM~Xu&T)0SxeV)Ay*yuW8=)YLD z$Oag%j2Jn!4KA9=l9t3eX#GxhJ)bgQs?_V~ADI7pVafiJ>kaEl9W`v>X&cKr#~(;G zlr$&rv#x|KRA$%eqi7eti7r*ImCL6~{>e}0^Rzryn_) z7NBx_Ec3Kk?Hingw%R%*|H=;kezsU33LTH=qzNtDiXO_T9j_zK=MOu}Y01{vQ043Q zR|!o<_?S-lsfyRU^L6Lifua(C@p#%{AD^;Z8|*ZOINcriQG5u0H1Rx(!J{|D=@@pB zepYs+GZqL1wgXv z?RFM|3vZ3D-44E+4*GArzMY?$8WSA}Oo<{MJ^h^{TH0FQGCK<+Vz(6EjUH*pQKU1u z#5ptkfXA279q9~lju1ca#n;_`9=U>D%WPl>U3k~{iF8anEtCcDd^-VOrw%5!pSjn^ zVn>5MFJE-qfM3lF{Qt3j?S3qrsy|&{Y_Ih;0+!#?U)i~ir$kT2zGH83kEG{=qX%Nk zGgZ0TLXCbFpObItkL>5iF(Bub|693#Px=o3gnhxhYFO861oVFed_um%uU&kLWqtSJ ze*rm3IOeu5MP=y3-hVh%YBj{h<8z|zGwb19M#By8`QaW-)>_;&@) zi-Hb}-qN=W54%pLk_+kwlKDA)^%-(#oBurEQ`n^5toxviQ?+P9y2Z`@;)u$VgfFzF zB)f=Q<(}ZNqe~(EhRU*K{iA@4u}ry>L)z8)XB|4-DlFzj5S*JRBwv2OR^k7JY}J0n zaWpQ>izGNVS;$VM{|ny2kpBxM5@klnWkvvUxzYb0v1La82V-XcMTmlPlZ50e49HgL zpFWXCOs@E1o|c){mJyN6nv{oQ;61hLz+2);yy6pPi}XCr+7C~`_a}%t?g0WVSNKjY?gNcN=*7Tr@r7F2 z4>rLNxzjEF!%NyvfTEWu!7$<=mF%@x+K={sx+_w5=cYpZaUVN!Y0kt3(th9+y`Tx( zAmfhyzyY`L9X{DBV*E#l)?>f{xA+}C>1%Y{horP0IYlpOf?>!(D(S1av>&d9py{J) z6y_|ehRCQEETJjquP823tuQP6fG1Kb@_^rDV73wv%aJfuxTsp(WOZ)hMxS9P#;NSf z@i0}Cs9H*7btU3P`r&=+Xn!6l!EEIrmeXOX08Z4;Qs25RPKD(2LTaVhE4kq>-t)|3 zv0dEx;g&8>uf<;5`}UL-x6;G8FC)?kpTf)cOm6Dk%X6UvQG2?Vn>FG`MPH6(cUD+O zLw6}eeFzuZ?WW~#B(CU;AVULvq{d3k#sfPH!3heFK;)ado`k%Dl}&5@{LN(E>u5y-Uo_0E4H!#siuFh=N+wI)o_RO(5r`TN^o^$+UJwbjjm41-)= z_43F*ZxSC4IlWQul{k*+;qA2%~XxkRmgRR-Hc%QM8S`zlS{&0amafUn2b zlk@wYPmivHV|VwqAkgirCsZrw@ZIdS@pb(5{WTLR1T5En`@Q$*bUXeTxZfDPyuQ9> z-tX>i?Yyom-DsVAGk=USyjrPMYQ27$S#k7sWUj5;sO_3t*f&6vc>T9yK7gV13h)bd zeGi8_0FDA%(L#W?LGQn>r!dcN+{O()iOla%v9HtJtKXk3Jpl2a%^aLEzGIu(b@1X( zWJ6*WaGj^>m8H+o%O6B5soEXgt>1rYXAcL@V!8LXb(?m2t5?2Dhy{VqHo`w68)weH zrPQ`NhQB|w6f|RFiCZmYLKNPSspY<*#sw4>fREM!q2tV7Zyk>tmm4-6eqCNKZ(oF) zAQmqj9lf8Qx4!LPruAMgPoIRvyeWS)Og|oLl`32L?7*SeWgo_bwtBX&01y4|`e4Fn z)`V2uy;zUQKDmD>@5EPSS5b7pCX}zT&)|dKg%t6VpV5$e!-(D@O&RmQgFYs$Rmj{+ zAb{DeKVRR;44WV_K-JxQFNVV*_F=Ka*#ev4GQjXMz_oK{fT^tszUCs{pp#r-oxHo= zda+rJ%~`fYah$qT{K~RXx498$Zv4~S7}(qx+}s%2+!)^67}?w&?Y*NkRdfm^uTz@E zT78)lHs93Uq^4rS_!1?1{p^1B%htUT_$q(#yk2QMd{z8ZdyPFfM)rOldhSFiWX37lCnnKOx!NfXZ4=Jel(y|9jS9{x+IGCm?@nVGBIa<_Fz99qm3GIp}TzW~08X zqfJluDgnZn9bWW&*rAMp8N=U(sNwW2<*Vl6x-%t{fJY4UV>LNRhKU5QOdSj71b+>0 z37c`EM~;Qa_{NH%r=PGBjckf+fGz8p+LTHsx@iyBA^Ug1lI3ZeVB$mwol(YCxyXpg zqu1KQvihYSOK&#`wu{L0Qb1B63_}7YBz-q;X*oC2!yQ)$OwCTTUni2qhdL80a?r)P!P4xHltu{E6yco@0$0|= zA00seSSB}y zTYsG~W~*4s9mx=-W0eb%U)d9#9+_thx=7086eBcbuR*PEbfKOI?w{LF&%obwNm&z( zY9|@Nm?zW?Xh3uSTUK@1?ZHqPuK?328tUDfXKng-)Sl)g7yw894c)?3+dx)s(V5~1 z`98K))}fJw75#Pr98k|4jKrNfs2psZXNjJvU9Yz1o@)r+YowT1>5dk+vI%*#CCwbd zF)aD~Kp+=lT*7V`PPakDqMO@Mb@FAOOsR_3!C|nS9gO3gD3KR0A13&3hh6eiS!pes zG_d1dh+}9%RvDRdhNxXwZ%XUHxic^~ve6dOL{E&Ra5%aGwAOQFGcI1baw2jhR%U^H zhtAq5);74jJWVv9_IQ7~Q7O7`RDF~q0U44wiGTzSJT!&D5=^x=UTzP!52(Ck^QBfo2qw6I1MJk&?s zGcopQA7Qcq1AAN1#9#c@Fwt-ue7~&1pXQ}(ZCa@$om=`FAjG1=KeuyZpJxguym)`u zD^2g^!PZ_W)(|L_Ysw?V=U{Q#hB%*2&XLlNkIAfO-3FiW;awPZ8*1yh4g+f@wS>B_b zq+<+AJPW8^!J2UHL7N9r+SJu@D&Kms?ETh)p}NRRLlqS?^tM@=6(a1@WWfsr$#ri$ zg2(AVkZSo8u0&Knw~((DuG^1luJ9<)cjYk{ zmGJakpTUWSFD)?kw2ejDi9$CV`EayC=Oe0wBR<$!n zr4AsgyR-SkkK5GOg;oE{DsI%8<3xUPb@p~^9u$3&bDk_@karA2?9L3{ybB%TtApYu ztksF)RSWG$1iq=ZdEK#f3bl&1a85OF$OFp&{dd&TE7M%Mn5$(iWvj16+HuuM`*k;5 z`rSiV-SPUBjYT>sHnlEWRCn;sijyw1_PI)_WGCi^Q0q+K+*OXGwjp@Eu}6^U)7y;_ zR{u<35SI9up-c_NRhD$qUw6_{kpB-%?J)fe>w$JP>CcI2hK=mQX#POV4WJ6h&MmBW zq^BpHHVaj7)jo1NXzmn{H_F7t`tx?Ti51&{`xR-`^WUlL^_`Nv!+TJ=`<-b#UIuE%nloxC!3;SLA~@#LQHKpr71N{`h9w-p~YSt9G^_7 zl5lfUy}w9v^2-bG#{+EtjN!3}eHf__xm#=vm(Ls_4Av_d(~Ug={^&ZmyMqLn->EZE4_Fi5R-UV z+24;-dA8toJXKnSTxt%IVS7l1v#H6HlKYuBez_zy38hkOnVh_&%p~iopq*{Cb~W&N zIr8bp{C%=qpH;947%uz@!1+RYCV(8!!R%t${t?{lfm2{n`iNwuIP@)cQX_#C+ z!hF8LpVT%gXGO)HRr}xNe6kKYDo7=&^ujUM6xP;6kw{CAm)>KEn0yvASpTw}_mJ0n zQcPqL6if=rF6EBKP4LsnBkiq_n5pa(6K*(s6KsDesy6NLYP11HOgbGFj4~sxF{9+a z;hzcR6pE;Ytmj`!MLLL+(N9i61PD)Z#>TVna!M4GUMwq1b3S(3^(g3Nev@Kbr5^F_bOTJSm3L1AiZjs8rUmem%X=+K=kL~ z=3br$2Dm?w+bPhY&G*qb1tL(s^`>T&dlJg}RUppkK}I=)H7M@Lt>E}#XUnq(1l7Trc--6y79NlM5o%Mlmg?pC>;UGYPgj zn|}|Tk)T~!KN*MC2TKjMm-!ea*?ec3zesMKRuHY&P%c1v8#39}jhDMo=&IvR-j4KX zXGknl@tAMnlj$3iNf)v3-Z)uP~Tz0bYt#A7#Bbo9k(KFTHrp z(S6CEsw|nVZ00fHVAVJ1Deg<^t3cFk?w@Zl!mMQVoU$&Oq%HPRpH`tqCcqUG~%_zzDyAwS`KxVWw1JQ#7 z*Umo~=5A5jAMNibqFDU4On~5J9)xS3x~Se06q!xPYukNm-ASRAL zb8rJWm zSe_$XTY?m(S$zP1)_Z#lA`b-y8G}n7haC%k(q%?2&t&7R@8x*AXy`o>*)GQ%*NWfv z@U>9G0Xuu@d&581>?&;+B^nFvHy=evkOU}e)GyF@jAs4?2}#VkiDgQb0wOb09qb*P zl?5F<>XUQ&m@RP{!6+Y2joQFfKW*2pL=^l#&ESVae0}v~iRz=ilPP}5(D_?7zKNEu z_*rz`VvBKfGr)7wSb%_19esF@B7R@t8_oY?56T@d;-_6~5EI$7A4E3&sE`LCR0OQA zemPn7dPkjD-bB77PWr8KX?W+(QM_@ zA$ae4VX0wt(?_=t-Dk8&$Nobrpw_5;lC$LkjA9XcT}JF>QTP$$NqwASGFhk6FRDVP zqH$yloDrpt39aOeL7gwI36+Kb{sa)K_-le+K^JLXMaO)kL46KKvF1TIH(8GpJ$^b^ z4h3@}Zhp-=1WFQVmUTo&BtkN$5G5a+7;%p*mPtmBiCxCX7@r*hzeto3k;vC5pUI(Z zX?7~gDUD&3F?*_S37&>(of?vnNIx!-qTlh1O0{6pGvI4W<&+#GmgS>(4m z3>fMYHIbCIVYB zS=Bx^$K(%$ex4zZHP3{MKPQnbOCG3+xL6+OCTZtWT?VE76Ju&$8VWP1igM(i#K3Xe zl+}LZ)-RqFV=(w)#t5J=4%Nmcl#}+kADMm1M#~LZut(E%=Oti#XO#qkIxz5`@T&UN z;ADbZXlYoS<${PtfxegXQ@%4Ac)|qJsI>uP-z!+-D5+R%BX<;r(X@OAs7$V_68Pf73=R2k`arCWrHrF5F`7Tz&F zJ}3Grc5q;QoEGr4u3YDX&8LWNuiHBp94`)Xg8F%JX!so+opCLeQC<|2COZK`GoD21*6l3 zHLW(*10H*r36>D|BF2t40hRV6B7&)i18m-}%Ayb-2?AigAuUkbbegr5rp0yo%j5(` zMYY}%?3#+BDTVj27#eWpa9xlG{`fe&wiDn?eefR{>&-g}>iAqaZ6`d#f?Jy}4XpD` z2#nH2%(p)%{Bgu6?`L(*1ez1Nx1|I#)1QmBmt&zREV=lrYS9`lj?)jlVX-X(iWVRK zNOeyh#R=d%gvl(bJDI&9675fYYOn)?%q%9z+Uprg03!_^D@kK8t~dGzYqpL`k_~N@ zPtaub(=3iQ4-o=qH+ci}Qn0Tb4d06jgtsHeCSqkj>}Y5;0|3 zDesfAfaPHRZNf?wy>&Go4U(C9)R4iup49%^Wc`LgnyCQWy)4s_f+?4yXUI=SZ)fgX z7pn3$`xE|7s)%aW*Q^yc$M<|6eyN`kkuKApy-jc4C{w~p&?l$D&*FkhNzV`5BpEJ{ zc40sXPTyAoZDZ0dZE?f}Wj_ac9t`7nR}$lNI$UI<${+5(syk$=dW&=>d^}#ox-`e- z$WUI4(6-u1_}@%>v|QI*%UbNlkHWE`joNe~9Vf-lSElkvU`etR_oj zU8N9Dn7a-_H~c(YipwrC8$D$5jBE7kgrRZRo6Ib|#>a+15QSZJyp8u+rkFY_bD#mN zebK20J!VNEq(KCZQMb-H+13Ul0BJn2ZP})d)0xD)Vr!?h> zL8r7oM^lk{zOc$7MnbPr3bkHgrh%APLcjS?Pvo$om728@m0-Ywy+2fNd~x%BLCIQ1 zsEUO9pq*MnQ(C>brQHQ3h9SHtw1NU4$4+2_3M0V)G&5yByuA!t7j?Xp$45{bykpy8 z3TWFrV-jV3ZbRj#zDT%Nt=93K_&RcDH8O=c^b5_Xxc&nuaj0f+&0b`b1Eq##mNz7Op)i$%RT1_R*6BauauJfuVJZM;X^y%p zf|N`OqSsHoFew!EY`-)UqhSp4WkhPXp^ObUheS1xsS}JVLGlykoVQ5Jt~3yGh9m#@ z5#+k;jDOUk-PoDQP=p}57-G&yaM4JYfs9Ul&!nm&7u(z=PavUrXzIi4 zIm>E6?yJMcaGWNy)YW|#I0jzh z?73X1g@-WvqGelvVq_D6Q!8(7rT8_?2%jJ1L`7EJp%dpNhH=SabDM4DE_1iXd9i}{oQ)SXS@+P zoW9_>66g@%;@B@O3i2%h$C+F!%mo z@tTi7;`Gx@7`KZn&Q){#$byr>jJot^0H;3yvI9pm`13;ax_j)zXu-WJ)f@#FMif#? zg>YDMH-;GFYC9}W4GzqVcz<0nK}*BC2mP5Hkjn+>XhY^tgnEt^nO+N4ggSd?SJQ)k zAA9B(p5S`Zf&pw=^Aa&$0}(10)Vx!v3tHe?_kBevlj~IQe!!|Gh9p7%z|G@YT0|hB z8h|%_v9~c|`Zb>cBU-zEUeZH}z(c>zN1d10VGG_I4zh+bfEA<&WhH`Q-c!lpl!hS) zZZIj7*uuGSagMV0Ciycj8qoHS>Yu1lu?i9xXCKA> zjy%F`DC#S0N7!Zyr}MEYXu>)EkGH6?L=i&L!OSl>yFJvh6+nj#jh{oS`V+OZ5EFvbYI&F^jP}5}xNalg=l)Nc;wxBgTKE2vE(Z@BKM*3BpB^wx6M1ZSZ$iLe0jFa~M#>?-r*L<0$g;5`i$`_w4+_}%+s6VONZ+}EJPl*#GH3%udjm0f z)U}$JYmVDcqUuB!QzXvf;{Y}I9-qWyubP>MC9E3p2Gt~wFd(k#W;4N@(C75&MWZ?F zq7+N==5Z8>CE>&6+cW=trw9AIB1v8CV17@+xDPR1;WZhkrC;~5>HBSVy{hr z*!MZ|GwP^7z;wa*amb5qzxObiPe-54n_s{8{E25|X@C^|HZfCvMPyTrT7$T8ze9=Q z=Vpap-b_5MN^B`2LB@G_! zqw@H@#pChZgLR&8v{BhxwGf(k;c&f20sgo&{N1x+B60sIkq8PzfbJwl0fqqopzFX( z7TfkOpNip~{$(|n6gs!wx+7nka2TYnA%E7FNra?oJY9G$+7NpuGiCJ1WK3c=tXw@m zoo>JVTz|if4&86XT=SBi-{mjD7Ys!Ed~G;g>V9akx3@;EA9%3vb4IoKz2CcsPa9`1 zPmdde_Z!RmXE^{E-qEwV4>^Fx>h3e-`6)^q!nD)=-Qour3YCAq#nk%O-gH|EkG8a4 zt(?0*5}#zBe06wzf0~~kKAAthoeu)HxAs;EkLTcm98*H~pU&^*pKo7Y?>9Z&kA#Qc z`um}yO3X%9FuXnHUtdn8-}n^I52b&fzllLWzQ4gil;yx7FhHO{U=oFgAsf&A%McOU zz0C>FAwWR#kU&6i6In5^0Tw0?d%G;n4VOJh6kjFvFOg#EQQC91LhnB_3AqOgd!U znC%}oTs)4;WmP0Q)syB4tt*L(lzW4EzvjIPU!P6Hq{~4DYOE?Vfrd#iedayHHOXK} z_J%-e+YHA-G>3ca?lBj%YL8j2rFdhWH!fMX3SpQ#Tb2{A?4cs1{T0TwWH1V9>z|@u z!&KuDaQ66y;H}Yj*R^Z<@~ybS{M6Q}eoo5jYa{(H=2G`3yulsY3iJ{5c7Cp)y$X9- zSikgbKuROUnQfnb1BTE=bYB)9iqf80X;{5U4Otg(0s6qI&gbCwcY&!-b&X;rQ3Obs%!&p!> z3a|L=nqty^6Eb~eF+0k?x2E)1EE!L^#$OxT@s2q$E>w#}ODIEcyX7JB?@d>AZn|Rs zt5rx!Os1pw1;hq=OZp8Q&JDM2!SywrgCI|VAoF14z_l~3Ddc|&|GXhSRk;r z(OpLI{JSc@$rSGOB)z+ry7h^8ME&6Fk$2^{Ga0N?80_zfRH)7Qk`GFEkHxIZH(t0U z*ly(~=7VzK51;fT7l8-m=)|+|gz@*g3qY89P*}Mk1R!8_x!%Ovs>)Ytf?|e)>0SR} zT7-|~)X6?P;8%kiCpU5Y&)OdI^bXV?*75EX@H-;oU^R2(kJF^|PtYdylB5y&mhDT= zwt_2|3xX4jgD%Ci`=WcOGR5ANv20y6(CO1w$yiB#_ZQjy`KZ)Ul82*=43V$e&Ihu* zXbYu)U6y9y(YKQ#WO&kz-wFpNqoOULJ~Dr&#;2-`+@z5RgilJFL9P5@$%p#6GKuD2 z(jxh5QXdLb7;a9Dz|!>Z|E)(^Xd5#A?sS&q*71&B_AC5NQZ=7M3|CncgW5=x%5z$DcK5b_gvKtgjBRC>^A-vl&G@2{EE1@{%N zL9sd93=gc7pWD;1<*rH*%Ds7FAgN`>9wf#HfH&D1VV6|dx1-TnHIst(y!#)%oJJkc z+cFvOykE!v-NJ@`uEZWvE$ODxT%FZp)(n*^zUN4Dmki8ALi!;!+y^cFCKGUSw*xN% z{L0Q7bpdhd&kwlT%ky4mmd;FuCqbQ*%6*s@{O@_fgpvI7A>Fkox2UK8I|@H%G~M$0 zy^EKVYctn)@X+q#GpELVUCpw_HyQV~D3@ctlVB$SmHVWg-yhY9C$zRcfTKM4F7*{m zpCp1giQqyS;z9dCFi9vr(Bl4PfT4p9aQiY*%8_6;!#iXiuTfTQIC^)ZVaLYz77IL2 zu(0F49`N@nF_&pw+JcI)hu}ITaZ%S+)6w8oMi|tOyW>=Apdo)Hdj&0}G*q|B={xn$ zomjV#yl0C|P*vwL`WD$0S)X|kOePeZpb-4m2tILZhx-Np|Idzz0>dzn=J)iV_=yvV zlz^@pId6lX5bCiI$`Jp<1qAlSaCN~3enUNLYv3&i;S;`Crh^G+W8cHYMXivbEUmh_ z1>B7w!$QSRy5zs|#j1wMLf`j7$j|gb$1}|Ck)zC&)sIt4$*=oUdmCH(&&-vn*n`bm zOUbD#=cA4*&yl0AsY|`b%$464U)SG0Ux4lHM{O$c{p&d#4}Xu3_UG-}+fN6(uFa1$ zA-&!z=A5Hg50_34zc#;Nq1;}_E`EWT+TK@1%-X{cz$cO1UfqI zoYaW?06l)gZ|7Lg?^1QWZSj9!#1Wr^TT}OY=FaaONN)Hd$^ysT(cOqnXMSI9p}2AD znmNaG%8hcjn4M4fx0>$C;Ebdpauye32mcX`iJ#a1qku<7pDJb6lWyef)ob)MAW zYb~2~6svR9;7=Ceel!OuR_Cilo-ES+XpV}}EO&6uE^*7!;V#9RE>Cu~InC1H8;v}! zwgJCN@F{5wnrVx9MmP2ax@YN*=8>ySKA{)AHa-u2(A&~qrDhv)3$`1&eb0S8-j6W0 z@2nqr+3J2Mc@!V-WIv5Q-hXV^gjo$L@&;KLUinnLEs}o;%=A*fxVyDv5Fp#dKxg0i z^R{So=DrQpU-Lel6QD*x^jfDCo_~H>&uZhl?QIITw{Mhx*P=`V#_(+CN$glf-RqPs zgVXCG(U&breXqeC>awEVrv&!{MnmU$ja(IxG*tT@gc5eY-ucG`k9IU`w6<*&71OwC zyUtBPwnel;@HK5*vzrYPWahIsbX<MVO-CDFTaJy*6DCtN2Qi_!h|qjI*o5J z7l5rN?9r(X;a*b!$sGK3S|i}B>@Mi10r{St<@bJ8m@bHA>Kh|@G|*MujA@q?Q8kRej}Y;bYCc>de0eWzWdd z`sCa;Zs<5#W3%(UBt?|a7Q6YeI&>~HkyS+?#P6?)PyJB8wx&N_`P37bEuixVo}q! zZ@wsBsk0Z-YtOjvcmpY~F_dRuh52?Cs2?4ZhNUrC@Uwe2F4)yv(@{HFgdTAG9q*EL?3|`FMOkjR#&xqy)}$r!1O4f8 zJyJp===-sjoVn93lXVY~xN2ztLpi@W2(d{qE&OAb5QAVd4zBQh|Hr<{2x7zX>Hgi&c)j)de3^cQ-S&BE_$#XRiUP@wjx}qJ9=pBg-|WEKksZS<&6y zJqwf5;tm#13h#mO0qKNy@8DpKqy!s<2rXl-2qrC3=`5sgctduv>Tv6I8QJDlP~NaE zZwvij`R_tzPsJNGZu+}20!o!=3;z_?N=Z?1pEbx!4N5O46{VRaTnc%D|M|JvES2Hk z7k~i^q1~Vx>h=cJQ}fLgcB+3DY?Ysdw<^nq6CUuJd}p6*voi1b$#gJ#V!%V^4CG5z zB1hU~+HPb>gltH$AI6`(YdrAy`p$i!caO14ex~NHP{>jiwZX+QCtwUz^^P1nE8mo3 zo0WXEv*nyR@D~0KzRe3;{QSIoSZE3~W5EM<`KZw!ngd`$3CX)%MC9>8k$*Z<{4T18 zlynFzl*Paem7B3a7{#T|S6>GAl9NYrvr$W149fDqr*NLm5`9W3&+eDm#q}8=EYfpu z)hF0;AA)s1;X50AH}DkRUx3q)+NASb$tO5S;WFWOSf8Q^lhYxZm9}pG=ax}8dszqw zy2&5>RZ#*<+|M{3uR7sK5O3T@bFq)Cey&m#QvAzQZkV>cs`2De%OCsq2oGd>e2G@r z8`!9wGL5($zv7_)XBXKR}~x?dgg85sBjD=+*N_3FW?BSgZhHZMskiKf=uM%qb+iaj(#%Rf`z@=?A{3{~+~+ z=F2e5QGvI3&(B88855}JR(27%<@lSb)P62QpP@xsnLMw?o+vQbHNDXA)6zLrJVnA| zm#5Ht8hN;GXk7BiFcl)u^L|aI5=qhoas)Tp#f>^EOiTC8(x#o-5_lknM`LTWJd{u9 zk-+jxhbic>#jkF)5g;t~`rQajIP(5WLyvWoj)%or<-0 zDI$5tg`hPk72@E<0B|c*Z;Qx&FU|+1mqmT7B-Rmwf7F0O*1AlYDoEv*Ndg8mxI7Z~7=M?re+^TIq~Cev%-SmKuqifxmk^wDzHSVox{B}VzGTTG+SDu zXeBK7yF5_V!rn{KZ(Cr@{Kzk)J-4)dWj>a}6(jIGIo?_Fs=IC!t~|V%Q?3N7J|n8H zAZFZb8YYF76iFvP1cwf8iZkUHy)%Hv?y^s>Eo60I5aCXt?I5#w>29K)D>6vADYViA3nL zj*LmIdifO1h>L%MX3c5eS{6K}YvYh2jp~r1jJhqa74NpOEz#O4pi|Vn;2$ZSiroDx zynKr(G;BvO!JXt^X^!Q_`*7oME|spYLbkCF$Ov>eD`0Y3+GDwi9Ccedq7^8?(%>Z)S4ehEGcEU%zICR$>ZNA8svDL3u(8WnPcT4TX<-v>Rpy=SSW)TIhnH)$pq zLNhy<{HFDLpJ#E}i3Ry|#Gcfag4(ui^N8`g)l3)@d57>#-@jRueeh5=gR=t}_{u{3 zG{EjBs{>iMcuIE8Az;(L1TU)WivNNQHE8ib&R?7{rN~7ZKoR(?$voZealF9x=s&A2&*lnZ^~z z-4B@~vZ(%OTe!65)|EQ{-Y+gWG5VkWBmi|``GVYMgOpVo4bjdB3vJYbQk0?yCw!SW z0m5HgYFKsQNe?72%I9jI(j&Yn`CqhMW_`}Blk8&+Fb{@N-lz6_jg=y|J*oVBNT)gRy42N zC4L~y$sq_dGum6|;(gHIl*nhk;V#{-edza*G>C81wLMUdvfFLws$(vxX96l9Q9LAaH+{(;{{*S zqR=t3PKj=GXMgbvq8=u7{-Kyd?1C^jhOu>-jwy?939C|PdvudKhIwctx(!spoeSd} zvSh)R8hWBi5ag_p-W3^&@ui*DpwtYVvVUcuO(Y{TB33!P?sAjKSPpPooJGYIg^H6m`T`oQcfi} zj74LL=T#e|&$t)Qho}u+yT}yrrqy!Vs97we^DlR`?gUYQKx%ykWLL(M?YuHFw}Zo|4dAfsnPe-b9hF7nSamPE;lchuy&)6b#YKN1E2zynXs{uu z9C(e`G3~KQpgBY|l6+jPiRWj(!C;nt_oe=+;1Wm%8<+6_iPJ>R8(XEU4>Qhts|3Tl zd%J)@-<0@TFJZR}cuZrl2204>Vvz>YDGn^t1&W2mk&(@#gs6zSq~q>~T`yhsxBomW zUF7Om>@4*=2rK!gyx3g&AH9tkCNl1HL#I}T$Gf)d+UEz?Ce3H1OAeB z6bh0<7FA`Yif#K5)|PxqyrHlY<5F2mEq>LGcfxk^0U8wx1T^=ui5IsT;G=1V{F!e< zTOXc6%w!P^K{2QfHbtz&3;n~tyh(!+97|h9&pZ@kCLWhIB6lc*DIb&eQtj`0Va+j_ z)=5;#6NF79QS~F5gBHUc_xGl3X{jX_Or}Y#S~$CT=_L!q}5^y?;s` zTtKo3*kdt#22Tz~VoxX_Ou?l*6rk^oW5*#=o-)x5#Af0?U ze&z8#yZ-}joq`yH32&Bv@qiqf@UZSh%yTULe)2d0+*FwJBDxE{mg>2j(0}V6|meexd-TLJ<#ibvcl4 z>yMUf((T3;7Mvqh(+gFq$=O$u^cz^}Pf>Az9$EsA5Z2uBsd3#2JK0L6g}6B1o_az& zw_AmJ58)S^iA%LORSbuJu@`v9T2pl~h-?r@1Ir*G!Ne`Yss@8mD=dfJFgL1^S4L_p zytBF%p>@vW~C)#{Nyk4j!W6Q}IQn%q);>@jHyNpd{a%fH&s z!kW_x&UuQ>EY*elS)Lu^;y~+lMl;R>h*pBV{F*osA(k$rN%^!%Xd=(pmtu%ji8nJd zw2p4(&V#r~D3ud3B`94^GC`BXxxbex3&8Wtu2T!FKq#ZH4a()`Q{9k$@F4E!3_B%_Jg{tecC>(HLD~@)Z)v>#r#g$-~w7 z2+NJ^rI9vLrgC#1hAVVizF1audmZY4r}PK9kA*53O%;U96QS^!-?rkX3685B^pIQJ zD%w-he+6jT*vk?BQ5h|y$m{@=p2z0U%ymUCdrd>rD3^vEP?ks;EJdU+T$ae+F?cPB zrk>Ia$mkPo_<{IFe7{r9&JI=qE)jP$YVWKl`5UQqLED2G?M5Vo^h`OafCOlO9@HP)c8?}!{9p??vDJ*k2+Ztd{)HPbK=pUXBhY5 zUi_tF3)tA(DLfZ;2CfNXHdr&X+&*sXhsoIJbjK00zpo2nB8>>FI(@&OJ4;-nGw+rfY(}WQ z!2ROAn*hVJKXm`sVp?M4+%nSq?;2N+2LnY%<# zY-hbPNjB!MfKuy1a7`)qV3IaPC(SCZ0!vr$<@wBN5cFz zo#?f;J3E-@gNx7iM-im3kziFi^(`U(uzOBCRSs>2oKSr^YK#v-ioacow`zLABon#> z2hM8`0&~eEP5ZWbJiL(FhJ{7TR9|F3IIW)Hh|P_@^iTCSS|T-vFj80TQWRpD;%>>O zP$v{N`#b&+41knfEo2Z}FPy5s-Av+M1POMqfmtq&e4R|ZF8-cl9NwcQiD08n=QhFofXctV~Zrsu81bOBO7^d4ZES5G z0{%kdx+BV@Vwi8tjS#OhBC1BsK@r3@aaO&PAdV918zDRuEf3gHv<=#1=7NE;`4eQZ zFA}Waa0*zSAM)~Kj*>COf<-Dp0k&_dlxOhCv9x0bwK6e*x@+EnUE36+yH!Ev>e#Dj zyDJn@xcONc2LrV6dEVH@<0^DC#)s+b00lxfuM!5PGJC7JwT)}LQoJS0rNp1``%rv0 z+m{{_{IeQgAEkeVd9mgoxIx<+ize7ScZ+zt*lE9{B%&0c24byaB0MZBndFqvWsZDD z*{N z_sh;iE3=cGeXS(dT3OE+l7tcUD_a%gB{~E}flgCYK9a?i#q0IObO+g~t5LrMh}G)H z{l;pAnR+61Fd{WR(7afj@vV)uG$p7HvX%$?w5{A;KY%$;P3O4NmWV`Sl<`4Km-7Qn z5GN8TEt11KE{`>w+(GL0B-{0|AmRfd5$lV$5>W zCi8?U|B_yzX|187Jxk!Li`sAk4E3Apy zh146OO$$6&+Bx5eefuFHhaqB2>VF2^Dgn!py#1&kK>w*A1+hOWNNZus!MsRfcXSD| zj|{32V)pC$1NIe8A9>kU;8TR`0+o~IiH8|_8L#(Py1YP{Vu4)xdNqKeR^typ2112% zRhv4kQ_~7{#a~fB({M-?5_~v0*KzaikOU$4W z9xP(Rm8}s*0WE0onr8qDcJ7F-e8kw5s;6odhwkjo9o_TZ9SyTnD`n^R}|S zL-_RkhBu1`V(zi($LzJ*(@7UJY;GzBmC^lZ;5M5p>N5O&^X{L(iBXHt`1eOK%Z2*Ku+qQs?P`7jy^kxr@muOdYCCKOeIF( zL0gYTaTKfmS*-0O&-dL3b0cQXUCpqut*1gKzQ%i_ zIapbjhO>Ma`={MABC%vz1Z-mc)WYu79ylFPo}KFdELFq+zdjeo<8{FvU;v)sZvUUH zZYa2+O+sFn@`1d-9g;J(Hcu&jNz5Es{0ey8XU0|3lOrJLSFVQqhwZT-QiYWHVvd#5 zKzZ~8!(_-aeiAdb8Aa=)V`ANTf-jKM9fVaCGSDXvzf}mR=QmBaT2S_R^l}79F<+1k zaB+^a^mf&g^tmAn1&KOm;@Ap{FadF2{}zHJxNP*`vRQpAPiK|NW=8jMI;bc6Ss;}n zhv0R>04-n#?K7=Wd%gv5zNGgqkj{X7W-N<@%S2#dqWHN>1D8>$iH0-~yAYBa>yyS0 zc;+{MuXk*CN%S>JnHnf({pdf)Q{7|dWvsT~w@!W`QrYAi@`+pp<_C+=-+t6(tBCK& z&8_a4maoa}+2-x8+?cliMBF5{;0x97A8JGASGDPIFUalL>;pcJ9XdbXBlZ#*;eO`6P6D{s#V^pn`S4!bVla6pgA~j?NF;zAYi7#0`m{P$7|@ z)?BZGgV9J=c8)GRZhAfE@ID(a|LXDHypAg67*Bj~u;fay#lAI6u1*}-FMd5HP`CG) zAB{Yzjd49C>SpN~YI_}jInJf)E?O=1#u)(w1H*=X%xz!{G2%wwEwXKiwqn9tDNCEwGC3!$QxDkbWh!__9Zw?DB05 z{Uz4h&yo?|`Hm~e4ce7pwc9fn`GQ9$Mow_KZ4FSr zoA4cv3Z;lOKfS6k(Y4t{+t3)vJh=x{zr^`!4*uJ3_FDj@0?BgtywuIAaiCg>BHNUp zzb+ug);Br*1qvxsmuO6SvKM5K;=21{M5aQHhRhqC9XX52)>ct8uO!tmr%6esd#WSB zz7PG016Z+$(v<`U#hGeR#Hg9Pqo}rUk1o3tDd4hAfz*9p?m9d~0s3Gu)7=D!wxzyr z^MBmleN7*Zb9&FH*Hri@Mlz2$aX#`+S@vfA?naK|?i-m3wI3t(t_D$|Y(mcqLKC>{ z3BMgqdtue;{Od}#xaQEbM;1|feoaaJ^@~?matR#v*CHp!QLBGU@bU#%wmIYW(Zmx- z?&`+#1;h)2^A#e)^dgfyb+#p-*okQKA&k{+zylqLaRk*ZF172BHZM7-^$U12SZx^@ z9XQ;#6@U{r=nWxt&uj zpB$e?kBhPJ=4p~=`Bv;CqIo~1k?^Voj`E(lO$Ifi4hxTU@`bc-4Aebh(YP}tJD-;L2ULIUw=oi^AB=c)w z0p$t{MU3?0fy;+m^)awNs=Or;>C@0{a(I#<@IW3_0L?f$et0)U_LKTuE5!Cr*;fxf% zbU8!3U|d?K@BOZ%urYGI8_R>R5ln42nV}N2c}^|EFRwxF9jtQNd)Y;D$34gk|8loN zUvJk+JLa5Wxb;$5jsnw*STMEf68hYuS&exKcFP&hRKG=pUuP2u;o$ErOpM5SzU;ap zRqV`y|3D)k`H!ZRx~Sk=yr_Tkd(1C}T*#mo;G0@X<)f00v5?W%cHA|LCf(4LEN-?b z!kY~uyXNDzV?`SB_J6P&xYT=;8?9t-lvg1yKy?}WxQwL|Nath66pJclX9|@WiZxGX z*>tv$KL01uAdN0xw zK84=klB>Lm-{l6axHHwm5bJlgxnOLEIoEAbURC4CS@_owOX|XSQsO%f+&54z6i(2O zkR`N$@Yz*#thIKe&x#}};~iUlT?B59v>P8E4zS_Mx0 z=-TRPEhg~Peg#qg3Bv)qn}5dZ#5l2LvMteI7pZyM8nQ$%72z0W_3P=YI%F+bV{i5B z9L8L?x5}QA&lEg_V?Q+hwGoYBlw&_Bn)M1u;)0WRAk4gOVd_4w_K@Zp$hNVg0C8GN z!r0@=IqnEDfFOyPrv^EEw|RB+jKbeHP2&9>y0J2Z^V%M9l$bnS(;A#67LPxaNj=hy zKUW~}{P?pSvu@m3T=0=O{988i4Yq{R@R^T}k09FEIjZ6PfS<>SWOAOS52xB&p@)Se z)>6$xQ7LU07{a9=@%vuzItp1_u$p7?tERBEXh zOQ2w`+gvXzQjr?-Dj6*8`F{Oqd^T?K@Y3n=-a_>1``S7?^!^)sR`c=(dem8ed9^db-?^;jq_Rrhu({A=% zkLPFL`uIzk#~rl38{X$VU3O}2`iFVPrM_rjmfx>ex2F1n6zmT1#L`7(a2<<;WlRkY87#p|m%f3#n4d3wC}1uC=uTe`?= zJG_PWbv+{G(u3w4^$kct%?>Xr%4JmCo>KX4Nq3=%y>e`LKHpqFv-ouWd~tclV*x>V zZTD>b@oU4a|IMh&`{OM~)H-4^pO>oV>(TVlHFf}4sB5(PczpB8?#8m=%NX$(7bJ6; zyC9=Bie!4Uuhi>|yJRZ&8JGZRyLONukl}6N8#w9OB{lpkVHRNGIFZCY;XVLu&v6L< zy#sIFxvRrET9q`fR~9n3_vatZQOwZbS=Yk97$AfZ<=$ z1uIUgCU46o+!n2ecq(i#Nsaa}et};D8nZ%9&tetHm#6VorY24@RfvIxAN1btaY2h< zY$S@miF)}8d>Gzvts0fbSYV*#}KWk8A$0|(UH zTI}_qlqAi|mkRYVtpD#e5WCN{cDaemON^WyW&%J=B6qo*PA55sc|adPflh>(3LU4- z{?$^@xj3kgbgRF5=*F}#BZ)m1W)VNEFy|I%7JgC$9z4ZMw5NjagF(*u!qMP8W5Cky ztgZ~^*q=|jgh9-MH54qe@7@i z#{-yV`kj9~)mM&M9^6pVILCmj%sSOQCuH&1mEZ%(n!lEhSN-T0fy7PmKJ4M1XEm~m zuI2Ffk)VqmT4ahl0RN{)xW=lLl$pM*BRq3(bZQXZ5)xRaESf!im(!wMSQJOSDZ$^9iEO^(>$zMP@_xWKuR6x`h!T=8(7P`<4Hw4a^nTFsf zH<$I@QA$!n&F|~7{sN+mdc>?P+zN4_fgPBzq;^Y^VW0;xKDFeC(AP{=;DbE0!OTw@MnJ^ubkx&^RoeUz4 zpkY?IguKxRn%McW(S$5*?ZvCUcuqibQZmCR>~lU{grg+_x>-99nBzbt_uwE9SBIRM z^!ki&9@_egfI$EVoo%59F2tdV5HU>9CnAnx*roy-X{n)6OS7n-;T-PK!<(xw)tYn!(?r-@USGdzs#!ZOJs6^Z^kt#CtSw(~eWrIbDHx`u#D> zr67t`JfyJfm!cqBEE+tqi{F4W#v>x;s`V{sUY5Zwp03RS@3=)dJD5J%kp593DTI(b zBC;}f+*)wqgx1*xnr@-BzCO=(c4j-XoULJ3b8%srU65+{c%Tr8AIDNKkgNfCN;idM zb8gYg%@Q-PBpM8wxM*S02OdaAlSA3%w}G$&K$}dT8*r=H3-kwZ81n!fD+!GtQ*8cj z*$hDzcXMcO3?cMhiPp;2PGQ*WOynk3*PEkYy!vsYB3m!Y(1n)bw&BokZ41=rTl*qQ^G_ElqLoYcO|}bp7UGqg;(jNEoKnE_v9Z?7^E^plI?nzlu6+V zC<5bPQ9~9iy|BxBXAl6JdFUEovy$zGhp0x17{3^3Exkx`5z@1A z8~tZiMTQlRXKS82S{AyvYfBJ=FE7K*c^BxQe}mZfNyV*gjIHO477)f1Kmi93O5Zn{ zV$HR2KtY!l?RoL?cd#Os?tZ@1OS6d={cx&3V(c8e_!1cgUM&IJiD{2aLM6V{ zO_s*dk2y_V*7xHRX0r6*0gvQqlwJipI}A+!_#oQyQiUQR6@fr0rUE1!u8&j@Nv~Fh zH#*&2pk=CwcHlGUH>ziS4sAT`bK_3d(TBe@7rPqcLk^ z+HjNOV_MLYV?Y4lrV6p)ax!Mi)Z)!KIo5c&_qS?;y#`XQ;5+6tCO&aoFEwe_#;rRv z>XCjT`~Ln9wl}8d+}Jj7138v zDhQ>X&h8Q`So`6!jQ6;sNCZ+J#o+EV=pr!Uh?OV5SXzI-);el9X=_AnL_`4gc?-lBTY!nDJr*ooErp zQnLrOKH%`wPUg>%YNMBQIe)Z46c&uwq%f^@Fnwa#*hLAi|49eb9PuwG)e_+S;x;}0 z>1W!_cgI7)pBbJk3dIfI%Gc&q_3SF>^?u)fRe4ez{k*>QyE~FPl4#Yn40hmo8U1w6bC=|w`_zo1vIPQR6J!=V^ zUBbLG3`${^+_Y~W@(1-po()(eP8EuiI$AxC_#j3h)yL3nuAIS*P|+`miZe#y0-zoa zC927iA8fUd;P2b#100Tii)%Dfw;kE>rA)@KxCZewlewfp4vglG*$tGzLSA`#cy^!~ z0i44S-jU}7@I}n8CcDmpJ3LP9y6<-KY&Dv@t*75MBs+2B?cK1imz=aL=N(Uel`3nv{i0PK@~)Ec^RDuU0Z5wm5l|CU$gO2WWE#Z&;p*LV;d z9s$cD?2pKjE$6t1;QcprLV`@|PVcz+{e3(?AboAcajomvZ-o3Ek3Aa^orf1xEG!2S zBaUYh*{X1~LQHQy0~^QU@#n|Khd}l$CMt*n1rJL|Jy;}Hp)D#lDG2pw7giHY8 zA5qlq{NJj=^6E0zt&+NS;&^0@)c(gX9>0qX|CsQzg=(EJ$E26D&TK!cp)&1Q&+`r(`p1<8-i+ctyLmfcTa0s|X?=5vrR~CL<=~p&KnjATkfX zGE(k6WyER=dU@Jvs!1F}Er2pmya^@9FoTJRMqa0%rjt2}RR@UBKJ-q9P&J|Qbs+PH5ec_tCne1PtheC-K$#dLPJAFb$&KxKekn&4MSBTFLu^onN3O;%cP(<2eqLE-M(Gft0=7OWU1vf z%nG=gWdCBWc4;gN?PL_QRq;?+p7{s3YN$cLz_FNWVo`KT^@Ey1P%y)SKc!cgkuw!5HU)7_ZE!uX=*m3a!V}!nmg~Hw%Pk<@bDffi%UHD#p|)s z>!84ACkhjmkJm{s-BUr!yP-lDWB8Z0#Jf)P^H{p2LVz_r~cQPtuvQHmT!66}&teVU56vS_X@FVu1sWdNX9PM(X zHYKjOk`-l|M`D3%5@selrG(f9`p`y~6f+W0BvH7pLSt3sM;;doa0h(UaVV(|VD0OI zAcsi-bPkJCy?#1;5!9Fy9NAV;*1t3vIp}QaMAn2q>1;&Onng2yVUd)!Z9xsE!#+3D zZmzo)#{)6gC(Ji2Syw);RihU`GrvEb4}*eU9!3WP4*|1uHKCwaK&FkUQ}3oj|I&gD zYQE4Z(%ahux_`AIvzk}!(rQAv62`^{BwHV)T>fRjh+Zmg znN=bRmjOo<>EV4d2#HCcKxqgp%&kx?0?$C_)XN&+>ZeVXK)PQ&n!aV(o#fP@ZQhR! zNVJirtDtLETXeOAqEPHPnW4;^Syv6s&(u~ASEYSN0FeT*Ff~=m=C#_!aebpKfA>6T zgx6U#gxZ*@-4M*_>C%s-M@81COL`m)9Ky5RKpQ~6p)uTTDc0jRPNrtPHIM^&J8nat zRtZq=iTAB~r#0ybzFbyS-d$y}y<}Jgcxe+k`GxZk8))P^`l+7k!J%EPR|F3ATXnf3 zeMMd^8k8UiI#jyVt122A_@@+^2#Siz3hl@Rg(<;A#_jD`8J`paz4-;ej2FywlL}K+ z3)SxEZsmH!^y(sk8Sa#5<5>t#fYxv*I6xVpOv8go{w;BZN>O*cpGc6D=4ovM{Bbu7 z$%&*(S9s>=FzJt*BZ!HRce{`8c-3I*$iageHy$X&N{LzhkVoX8m%=3KKWANImU^{M zz^Y6cpIDkO@|^%gEMUgSaI_h7?|#~k*0M^`IxInzzeJh$=3~!LP8NBNw;A3 zX%R<#_;phVQ0$bIKhP%7N96}@XbFn5(K?HxBxtY2@~D8)-i;GVc)#MZs>{v{i1sbY^iT}9 zu}i0qQ?HN;!g4)uY-5wv=I$&ToY#h>g2;r!{$)d3#uX{Gv0mq3KQh;aM;e98VPfV3 zXL?trv-t?}Q{CKO>y2TB)KI5Zwjx!VEdqCq{Iq+DbSN0Mvz(y1NFz~*AB8e-sF0U=D(`7c})AyPyb>mDoI z{%%vwz>Qxz0Aykz02rNQEmXaV$1p5iOv8-zV6*}wMts>t9j3!9EbmD$_2O+`H>5+5R^pEVP%`q7Ko@g6J?R5)w z{=p8$VkCKh2{M(I!eW5C(1h#$99+H^C-yeOfGP<9ncOnq4LE4Fl|s2uP&*omoD+=A zfAE|)BnLhatI9gZDLY~gSe|zpVr9n{#I`a6&@9Dy;B#ZtD zXd%`96~z-OkZ(&XDJlOKI}ygtEjk>L&PWRYV`pfs-pd&x33fB&lTSD#j7Y>3QDAgY zqEw!m>Pn67Hgvdxq)B97AG$-KjksLosYH!Hvf_YN!+86!ggay{!_y^eiTx9EW?!D* z+FrYfs<~2h?ri!G4xlWV&jbB8{eQ049wz zjOFxqx`)no;tO}B*Y_9yTWzZZhvV*5F(9k{W}`jD!a62dEa3s}GWFi&o2ew)6D4QXwewx5T?qxNk>`ko5n*VO9555+J&MP-SJl- zCy-l+{8ANNRHk>9L0AnIR{nydXSj8KP6N%^I>JKGQ(L>LhLO1#7L4AdX=<;r(3-qp>$)UuUQ3%D4i5-KEoiYF4J?N=UXJ{L+e<1KT}wU{5+%mJYGD?^xpoqz4ra&?rM=&q+hStrb3kFQAVscyL1Zb zx`pHBd!XhBl&^8yRx<~AHV)HkxpbCLW0q@x(*Kq2Lf6~ z`R_<1)d3V39FV24?X<^+SFeSHr%t!l@f;bw#jwhz%?EIP-Ay>-_v6Voh!H z=bx{21CO&xP}$5M4fr&Dnfh!07*RJ25+uu8uP&>M0MKcfQnSfkLZDxT*rIW7lEZPY zOtI5dqsf*ob=gG;5^~Ev!s!sjR5>=d86uw6=xa20e>qpxTheZHaYfkR zs_O1aQOD9x1-ec6<#A6WXltDfUos9~GnWc-_Z9QWvTigU3i{%bquO~CISkCv0{_5p zyb`S|0Ki5(<}@KJ*{oPGGSN@$iwbJy#vg-z<2Ju`Ic_04dJn$0-y3q~t49`Cs5D3) z-H_VtVRs#fFfy5j@@IWlFW}q3Gzj-|ackY&UT6I6m~EE)n6Pva^6UHH-V8hlh;L$* z*oQWQ{^K*{a9kC13CT=IX4K#-zLqO6+0PG`6A*<mb_qMCjfSs|B4RT@h{kk7t-X6Ucb|WgCx~-G1{S`DA$%6)oy-?)RZ@1SWnU@u} z4;c9bh+`18687}A0#z-}-&t3!>5%q&{_(9sJver`k5mX!#8iy3#C(Y-$biPskJGoA zsA)O_W7a|?=@^X=S&`UCUZ?H>w2?^+N@&{3&6GZa>CN_++#7*$KDi)VwdtgM3B+w>ZWmdBs0vx%n z%k=TNC)qNjW~1l}K4{xsK;Aopfm{TZ(t^do=nIx~IEZR>UxzB6r2R(*r@5L^iN;azG^RWld-r!mMK@z+Pmaj zwZ<>{TVHx=oV1Dq#8`$x<5jBZ)*%kWyIi;+9QLNLyA~y%L=gV~tV@Q}0nn<{cz{Jq z#1sb(&)a!RcKxfx47`62Q2t<9P&QX?%YO(xnqmvAf%2zd3C}A z!ka#ymM(~1Q-*4YQV6BE0t8g9@G-K;Xy)SfR+D|Y2dXWp={XIg$M6NX^ok;L*f z+fC#m%pw%{p2H&UBHSMN+rmM;;L*vGV$&+sIagIbw*9zmzEY8#o;<)fk_)dnl&jvS zu&Z^oYev^#oOqRl?Qd=3xytPy@YB#O-qUOtAEAYO>t&K>;?hf80Jq9nEab@XX7~4l zyCHqYr^QIyR?N~CTBG?3lWu)zqt;R88r6zW&OOPBY11#@QU7gt`k_<)0OMU)d+hEl zzN($((7tkf&e}oPsmx2zMsEN2iHzkrs`&)f=~u*76aQ$&ADW?T+%hLg$APMHv4^oX zb?x`gO@V||TQRB|f|_j3WzG=z$d#1U2LaH3$Jby-Z>}p1z56V{0JCIS>2?3H99$Sz zitgY8S6DVl$%4(VF3XO^F|?pg(<m952b{jd89QFymk~PGZF<5Cs{h{ASLzq`x=V z;7f`_mR0BnCqNjqk>in3td#Q*IZ<}K9KdWhq^8PC2NuUViAFZ72&7H%ZWQ!tYZ7N4 zi#C6RSGhMqa(=dd0MZUg%Hn?@;WFdHVkD--OzsWO@O!aBut_P*8N;Ezp12t1zO-hj zQA^RTW?s@`{*>BGLHu#PuELDAT^F;R8@YLf_SNO*c`ghQa_KPgi->AS!pf7&G@?zL zRa2*PucYcDT+v{_%He3YU0P^w()T9w+s6N*;$nZ3`!o>d=GpO&%|HmuPD(wv>ek6O z!blXwd}pTrC!0a@;c@QxQFdK`hQpA2;Tmc_D%Tk9<}ky%M2q0Qk0E;h|xQo!fP;$QpiZJ)2l%@O)s{?4|yZN%;Bug7tK{@4ET^EF>L!S~bE z^K{J=1|Pu7>2dw}8t`#^zP!El{j@vZVGnq}8ws602E5kL>+^TL`+jZzTp#m!8CyfJ z_4#($f=JK}czby}3MKIM{5-YUIZMsm?sMloqcRqYUkD|u4wCIYPm$w{j z=zgzq96RfgJ63l)bwGZqjPVvWhjvtxXfBk)2Jn5fqcM4P4KaR&qI|Y5s+th z(clI3fIR?!75!Yn0K}XB)gpkv{=#QG*0>5Zs!d2vXijk6I2Q%PJCv}~v}k!r%Rx?f zyvBh8;wfMqDbOk*LZP{S}Z>71?2m({!3<_7#-- zK!LzW)GAZTv0ju1vf{M|?xjeHJm*T~1L6eYT=IWX@D~P;*?gMsPKCjxa;PNO1nusJ z!L^RUr*bIkt%JDC2MLA2tt+kQ%?DY>^gUKMGUI42fv)l+yh*YJdvg)th% z40m)3&5@OgQQL_taE4%rRj%qw?lf_xOh}7lYHMi@J%xKdfhGZK0&F6AfbHX{%U^KF zDmL!2nNH7mPg6HYRHX_vz1q&#gpR5fJfI1fa9(W0ho!tr2!F7mXc6mgH;L#ZE;?Mz z(qNj`Mb=_!(L1u%AR3hZXnQo3F~No4yBS_LEoyPYQ^Y z#SlmlP!m`ZQ1Q}I>p)q}TL6t?GqS)3(FD;1)&x}qr1S3#4)5|zTbf051ryOC6#icY zHUXpS{jc8R6+tX>?ETd#LH`ZV+2`cq2cK0UZSOzfQHJJVMTVCf;Q z^F&ZMOJ0q~d}4Z@#cdNv4%oPMvUTcNM*3Vsbd7zhyI|zP%q!`jmYTmVfp#euz{Gu& z37H9<2w~p>d0&5e;b$}gNZ9d-rh0b;Hv_)%+>Qja2zjcq_9p%SAcBq)U^Q}xh0}q5 zB>2<#UHI8tpZ%FZSe-HRQ*KyeXmPu>LQgsM`)+7C`ceTifg=G7(8~%BjOnM6mc?AGILs92~{ zj`vL9UBK%ONJ{Bwr1?aWf1`l2OS(@TsJWN+{S2Pt@gz{GZ=1D)S#1Met1+ZM7$zZRBd#GcuLmmNEr{07 zdibvphCs=qw}qO&2lyHc4OOi$X!AEcIOjRC4Yofujzcpjt_*9_9qVMAQk9KFc>~OK zqZr3A?mn2yj|Y({5<=sPIq}Y%w9N_oS%|Vo3 zCCTr9voHyxztvcdoq3I#0!f-;o!YC}xHr|tE6$dPjGgC;u*#$0F&9tv+B50r!j5J| zSgf&8pe>1|sJm3y)g~Q_a;D1hskhn2|^()g-+-* zRLnL%Ny*rmfks)8EKSfbRRI>+@NS;R#b*X-4kg%6a8Hl;#oNI*ymzAP~>oMe|C_W^h#54Yck)21?qTywT0F>EJ|KzjoK)5Kj zuchSV0-4?dP0DsjsR+6R8z{H?0#!V2&%fJinYl~ya!yyfcAM7lk{H@7qw zlMA@%Yp`>fy4N*8s}_@q+saj=XJM(^#qY(KvZC}vovV&qF>yi)h}%t_xNRubRgpIb z+OoM!PmSm}$2smF0oCQj!||pc&aa&#@#vg$E@dQ}R2LGz21JsGNSTCmNfuZm9v7q+ z+r{cSBw`%1M6eeY^Qs|SSnFInve)QLHMZvHDz4;3j~Ii!%I(r0l+YEsld@E4WWp=` zZTxKfFZ?Ta@*Tq~r6r|^rEF1F2d1bnSf1OOok6ECM)5~^0iK+83H24NDD}4slj}=E z=wV)x=V@FJdwkPe4ev(qWuk28VVT^pQtV!7(J+I_S?J}9!^LJydc;m|w|720gRg%{ zHlHsgo+mlyI1@*qQ;OSN<(j-B?j4U+#wY2N8cA70fhm+4@&Dqe^On7%c_CSC%rE7z zUXk>%Xur1#15O2PkS4D!ti`o|-j7x%-kD2@`y5TO^bfJ-gVLtl7VdWN+Q2#!7*XCk zN6{tv#jqD5b{TTBYhzQS(|OL{T9>fJDejCd0*fz!`?>S>=grck^J9KQ7hJ>4jmL`j!T87;2*HI;2CqQl?GjB!fHzigL?L?CKl2O5i??1F|N7;1 z3AF@Izv1UZ%LI*mRcVPfA)jE3m}U{NJH>q0jD_B4{n>E{?lh&RBnEu~e+@4CeAPjB z7yf1&xuSx2gY|azho!&S0Y~V}`}(EEf8@4=GFKeu2G*k~`Om9rz>VeTnSRr~hA@Er zNQc-m2!P&c&VO#TrO`g{6p;1q(y(FNN58r9Jh88wK1;7_sx5d5?1^O4^ns%7dda&_ zwi(tjb`|&4GZKLMjQhKN`~rQ@rVtg>o+Nt)&p0+1+AYLvgi;&>XGk-K#03Fs=xK%1 zWhZ2Vfik~Fnh-%6PGFHs%uxL>IK-OGXcf1I zvVh47Mz7PxC_PNCR5^4zfFWK>E|3V>45o8l_kJuzFDt#&9hl7<2a04Vu_54Tg| zUSc-k*Q|k(4t>@4)8YtprYQO-#;BnmK)JMEH|t*G`bV{yEl+({Hs{X{T!r&n)g@Q7 zE2TT<%5>yTE`;@I38Y7$PVkjCXO^5qaYbKIC-gN)WlN)w6?#9-S_^&E zH-O|P3;0Udg(e*Wx+V=ZavRdL`SX@(J@he?}%Ii6dsA86<$toZvaY%evq{=< zI5vANRV6a)==@o>9 zbV@WSmrW`}V6vqmc9N7(*FRRiZA>oSqb*?)jjqwN`lRI2tY`dN4>&$!`@EviAXs+* zC2R{#iaU0+BZh~?_keRNekNiDC2mW>5%FvVv$l%7s9wYApeva)c33N**eyFjWFNHo z(Ij!z_uzFuV+JN}tB?s1(3@`?Zd0EW#KG3i04ud=SIm$r>26#Ii?st2#=@*uab;1Y ze7i<1UbDRt*4w>58aOMCpF#jFnYKp)QfW@e!e^i@5Br*SkpEZD@!UhfT(zs(gajld zrm?Ct$y??wNNd_0Q<`5}Uc#QC4br8`H|Ual;xkqtMxZFMRuMP`uyA`sbo3=oC{Aci z=*ipHjqQ+g4s)yG?|wc60WhtkLIUx$R@`LaQQfHnIftpFsvVR(A&Gg}=f%W9x@A@t z9;SEtMg zZmzrN=7k-)YQ#g#PsYg}Ev42woZv;H5ND}pq1Va*jgjds+X9p{Svs!ncsm|M7qM2< z2ExEVnwkieWXt^I;txm_B|N;S$c2sCDU+^>GWff<_4@(nw4j54X#CwXdi|_ef-L@p zJyW1S5ov+kw)+DwT67M?N4Zmw`n&fK`@4g(`uo`G@Sqs6wac+BQzOyKX$(@49M~O+ zn_f^O#Rh8lwF??;D)`%iKcTyadlPM^a{$LrO>t)9dDRHDvjsZm?kU)KdR5Z>IuYC? zycE>sfJ*>WPv)<@J`<)b%c{hJ-*dNDjF;&(>{e9IL=~Hi5t8vhP?De4?VZ+t1P3Ib zu=67=rtR|td16r7p5_#eRKU*-#7S}uHN`?I)KC`x(QSOt*c>?oE-GwaKCN5%^n4t! zK4`^qY|3QwJOZY~yO}ZoN=AIpcwuWaf2J#ZzO@B-wyszV+HYSfcdE49c$re5pK)Hh zE&M!>^Qsl5J?<6NFNkSIx+rmUf1R0$q%9 zW62sYvv}+$g;h;jm(Q8^AWdo0ps}eDYEN}~L^B=ackFnM)0@*g1OY90N^Oj}`EY>d zAB**<05WCzK}{l?UwfFNBOWgFqyR~ea=Zs6&_^X7=+7Kg)MGJxJMXmHaol}_kkkrV z&bduarDI3R+XNCaJz}N3w(PYj-Hn6R?6G(hdQKVaqK^AD>$u_$CvKN9gJzOV-IO^z zMdEf6DG@i3@Dsg}Ld9jb5}CPcj}Cwp<&m^Zs&nanl|inWNCkgQm!mVP3GL8PxMrH2 zJq@;mZBcMT9dJye!%{Uc_haGah^}l3_KGv%uLQN30$}dgGF@y59G86iT36tBh&eGd znsc>bV~vqcXFvRbv3LXqPMPB(`$jcFzBzVJ@3V_)ZDJhS6>CP>B)VDa8Ye)ubGV+@ z;YrA-bqzDny!_^wM%F&t@CPt4UfwHcj9usklP7~S^irTek$WS)i0+(r`*f3A(YkZ) zY+&sNZj101%mnSug}=o1NmZF^(ZPe70cjA(fVO|U-`c(yHSADyN>fEgO??G5l9lw| zR;E2Q8mws-y9jDJSP(XmG-yB(*SOHem^A-U7T416Kju5Qb|YuMNWjaJVN?T&@@bvr zHuof^Q*cjbP~zWaX_vc`vFD|Ng_w{j=W)wPvMn1`N;IXU#zl%68`u6!afz}#?3HU* z8|&Bn^@KZrNf=wOuEEU#m#DL>f`TtyR^2BVDtX1NAZ$^VmgG#rr3?k2#5+-{I9JgHOn5hqFN-@Y>E96z~u#(_vtw=2Tk z?@yn=35|Fw>0?V=jhxIw6C9M?%v0>;Em`;^Apd zK>^&x7F7yrmQ@v(q)x5Ms#D*(B0SVGsC!o8o6AeSc%Ea~z2LO=oBGNSmOhcCW?Tnn zCL|tuvCbjGM>k@s;lX3!=eJa4yh>S_9(DJw)V|WST3bBBmVFD3nf9DnyKwG2hdc9b z3tQf;O3;52qL6p~tlM=d;H@z`er{8`o0H+HB~YGTZxk2*@6B8N|G+)VkQ3t>nRFSz zXT~!yFeoyVwEwkO%(&U^Un?Wm9ox$h_t+R19`sB;``?@CpzKsBMhC{1Q==JOn4IFL zE@adKUz|PlJfj$sK+5EWeWH^Kl3AyhGBXNHe%&Cz12hl{)-?iU#U}GNvQGD4WYl6> z+A;YzMn(Y{lmqHv8o+c|KTwzS^a~(W-~*dw7#OZrGB5!5YaxM(DIlAt3oK>z>% delta 33200 zcmY(p18|@}^e$Z6wr$(ncB`%3Zf)D`Tif2+Hn+Bot!>-9zyG}-=1xv#&dkZ=OmdQw zC&^P74KW-JQ8$bQXEw%TiUc1Q`)(zHBMY@hy9Q%TI~ORsGbANkBeJi{vD-Mg-?~wyc!OaPeEg4vohQ{pll?X zCbf&6lb^fF2;G&JC5mKe>EyVs>jM_j9DOJUwLc1Br}s+{joNH zXH1sayoqJh{>y?Z+Jis0sKRsWHbUG=526zk>E^%TY@VaX@yZpsPzV;_y=ww+EKCuE z4tAHKdpNsWvMCpEh;$}I6@S`4zqevWG%o?J68+P z1X!NpAH)7D$36Gl9zM4(d$&XT*2HB3uAKuPN`fBekLg?fk?a4hoa?j?30)930Ha@|?_tRGVHd)U-;-bL z?=%0OLJ0bly9$_n|M@iU6g+qd+=q{4=IP$~{}nNg4*l@^>yF*$`~T_b|8#XhEL02N z5FGQLHslge3XS>ET}HIh&KwEXzp7k~0u9W*dmO8Ba`Bqw6R^9CuH-#pa9EiMW2VuL zS^(FfJFiB;*AKSljqs1c3wkEV`RYO1xax;%<t4?QmtgjnZpqrruN8i^S_jS~DWr z7x4L|-n3UYa!3^f$ zcO?a*?+aaiZd3BNv%=?0S#dp;YSVs7Om=OPGHMi>d|EPNyZp0ZOi5@aeE4(Cc<94q zbHtlQX`3s5Y9k1%B*?NQeGtIlN%1H?8^nRBln`5{sKYL`0C3Q)uwq`M!@0>p@|Oe> zs`Onc{a+$qWF=*0IyA;9_1xGnJ7>S&22&Q2`WD)?y94R21a$*gwU-oC@k;Q*O8LS5ZVH|WBq=mAaKMj5jYKj0R>!zX)1O!#1< z=s_4`{&6=^cg4O0Ak`zegg@r}sDdXn@;yNz3^pJw7(j6$2t*REOOSdPRXoVv6p$ul z%;kY2-`wI0YgVX3G3w^Mcs{to>o^3m)?v@gEFmU6rzHN=ro4JMJ6{mTexo?I)re@g zDRiafHan_Ce-1c4FZR~NqTt`RglzWh^t9R?tb9McS;hbE$r;8TxUup`co6qWDAriU zw!Aw#d-KW&aeO(;EhM}_dEajHeKTlQP1bFJa~rdEi`j(z-gU6OAkOY=elJ34YbFE@ zN9-uL#78A~LeBa~a!kf-oFP<@grkS5Ua}wr0lD@`+O5L{*qA(QZHj*DC=f`e`srJK zgNuFcK+!;1xIcfqeadgJu`&J8va(*@kB#JU zR|x$dKC!6uiuij`#J)k*Uk;xbsqO(F4;@ zhx^dm9={&IPi>LNJ}ln5^FL45Gv2M4Bj)ihm%!KV*Cn&Oi~I4d+sEnp!qMSTEA-_1 zO#0>q-P(sR!Cl;QD|6=Z)aE+O!PAh)Ca=c(KOvf5TR_(cg2k%4-jX}9+qs9XzS-&3 z*MXpZ{>1wuaqV!AyG0+cZu9j^*yrudkQ*#!`ElSawWQlQ==-%kr<#~Z=wdnvA@hk? z9!UK{OnlEMd9{}S`nXRYOpjYLmmh8JZw|lC*WDe!(|6C`u8y9=TK^rz9lm|7KXWG^ zX+mko+%ESB)#%&TBjQZb%#nY4+`F-RemA@tL-XSqQ_OG=65pl=q;)baz2WwzF(G9MD*BycK)~<1CU~J$$lS}oA00cROgvbSAy-d>gq9mb zr{%x)Cz&)?A$!&!kKOu0emhuV`_%vRI*jG8jC)usQCgNCTcrKNOG%uK)|NYE_iy^^ z-!#)`3DQr8gO@{TsF$NVw}(Y4oTTt7@18JVA9e$GEE$oP}OSe zc|yMABh;VBr^Hz!+vH~{D=B2FO=PQKK|^8EV%=_hDmhw@n(FhPESaN;(abrJ7%pI# z(9BvzJk-;HtNfy&(wt#&6lyjZY+#_RD>ucWhP7zcC`!Fhnqlk0;jNUh0Tfc|1nBoE z8nFt6{t+~Da~@f%2;DPl`=-X8v$xrlft9Rg;+in1*J}K-|NUFQL9=d&(PU>@@@~;u{9p}u4uw(*O)*hY zHJ#j>1GnE#ufkjA!3GT!>!_7-fKo)~*5Dl7?R+G2#8ApMOXq)!I(+x3)8$Q+_Y`q*QL4G9&s=dX z_iR&!yoD4q%22D*HsF`GTQDxUw~t)M$B-Udg&cAF3^FXiY|@&Bl|k0_*0gO7`jKTO zYM_kDd-{&2INJ8kSM*=$2jpcecYuNQJso|bRk!)8dR^QG5L012WI0zhBkzats|NAU z6_!MI*EDUB&|_>iG4jT^`PR5Hg6;X=J9Q?=A1f&{hj3MkK70t|!i@j08;1T^p<>a^ z?I=6=E;!3BNiia%a-JBDW|*p!6f7FW{ugdH0(A}sYu4322ySGNm0;?14R`~zPaJj> zj3NA~XL*y_T zn3z>%6%Enz{i$f0q6*fuW~(%`NoD;N0g`Hz<nWn8qf?;`z4(fz<$TCsM~0-VEI}%&U{P09Ijx= zkV`_oCUNi6Le6F#^g^C>1Fb;P;lZ!#nXr!1Inyq@>=tTs$Jt~JcWRAT^F?~9Fe!zo z49S1L-@t)oQA8C zmWs=Onvp*{9JvG4VOB`*l1%6G~dzPxZ%QoUW}JUe{XgN`({QsHOh`Li*1g zP@PK1bFv7h*n{R}u*ci|cIa$F7F1?1sNS(}$zO_Ig}} zsZod8RA&|EM%`$@EU?N`@4?$;i0>Z&WM#{AvG8N%C!&?7jiQ3VDU}3BGkNfc9b_m- z9Rg@8SZ5|*OmcS;BwUe0^M)iSLh`MP;1kUt^*VI+E!3O8l3RM)ESB0L$5PiINu z7A$7l((Cj0JBq=n(yfb35yG6~X+saju*N;8VLn`?cTnwjrS9q}TrjwY8^#TQnFR)g zf(Cy9oe4)YO{CiixT)95NUH-ax@1^5Z5j|7*W^-R(-M8n9C<>SIX9Q}Wtj0Wf(n;D72XH&q z+}9fjvQDg8fsuIg=1@h(>!Vd*OThjBw`%3f`0@iR##cvcEQt4_&XQ?jBev76H4N5< zeSl3-KWBYUiF*LRnxc+>4Dh?ox6ALp^F2b^qdxR3!y&rIiWSKH>wGv4cNj0v+^zj=vB$!KZX@vt4c&6PO?#;&#=_vofn{@0W*Z$(T2wQ@##OZ5*E7qw z80w-avIT7-3s<=o->u~9$W>%3(<&V`J(hsMM0bbJsAGA^C?T;-9h0CwXsxd%eDz0K!{XPsRLaT4dyz=6|vTqAKA zn@d=Ad8D2W!(<&DXh8Ioj(oFUCHbrpuC)+ly1f0>ppZoR8J1}dS~UEx!{rhYn3Ya$r@0Q-{cw9v*VoUHgP43FNe1sI)FA}xDjMrbj+tP{MbskBZEXcR%3R&7XHyM4BTu~|PiR>-(fAp4 z?Z+GOYZTn7g!gj_n+SfhH%=4XtS%G` z$nk|VYAy`e#@)rgI>c`ozjAb6pH`g9#Y=gdCknz`E3TaYlR8j!vQZUtP#GFxZUhNG zYS_1`AhbzP4cM5~V+v(*p?|iNy+8Iq_*ZIlU!L!j(b{JbQe$Xbve=6j_L5B%3vIPt z3UmODqfk0uE5e1=F)tfkK52WU9|mv$TJN7o+*MGqlXw<4&p>?-|kg~B6*7pJR8rxm5X;&+TN zv;i9mjl-m7K&JbS;^$nqVrhT*>!9O^nrz^Q zkuioB!A+9c#ZF#uLu9sOAODsr6ie1aFyK-y@TRlT>16%i3cYh2h^l^o@Z%jw$E3+u zfF2->KhvLZL$(6Dpw^+`x;Wogz6&?~=#dgjD+2T2s$_QYIy7&w23W-xCK?ojjG#~q zjHY|sH*T)GL8&eUf4tBl3@3>(@&g!yn_M3(!?oiOv%ASh^3Y*eS)`B#7^ArY;53LD zoEK&A(@*ELuH>rLRGPKx)Z~t=j_5Ger6$1$W?59APADx zY=uFTFL0?7y2cYsB4WPz*&M+Nh^oj2`YCb)y5-GhBV`rEeAdwdvtXd-WPoACv~n}J zv`#>Oy}wXV#ebQhqG4sY;?BsQ0Z4Bg}01&`$&SkEUF(WOjWvY*E4!*5G_3Rd-Ta z+mOGQPPtALRIwR>zvBH)>9jVuFq?ljv5tH8CXrT^lB|Y@#FZkJ4+2BV&}CB`oLMlK zoZ>XYjiK6drP}vvTPd8VgB~L&5g-%xPXHp*TdMEnqnO`Asy4)EkSYx)0HC(Dx`Q;H+33oLD@k&;b6I-6i500wwHyEgQHhiNpO|s0> zLLBl&B2KG^JX4h*Jo*MtJSHcOPoW85lYgYSNlu-wEJ?aO$De|dpw~C*{-{)7aUqu% zs;{s+F)WHLJ^&PcvPH(lET$ivU}ZrexOW#Ls~t_!3W3@n7R*04NiNZaV1i29|LvPg z8~ha$JYdxQ+eP70_GlA$-XR@2;fbr*gMhukI47Xa*p%~2@^4`h$*?-ACZ4qEL{{!7 z)@&mNVd4JhG&BFN`QX5$l2>8G3ykr6yMOXZR|v4^WjesVk8z{)p=`UH5W-N6Hp0<4`BuL~y{yks{uO8KO&;VcDJ8$_+J8);A4JX z$9f0NiHPri;OMWx2J9AeD_YO=XfIlvRu*N(QV+{s1|Cu%ajs#^fNZm`DUR$ff`g@=hoI zyiI6Lw{lr8&|W744n+gS2q&|)Qw<|Vi>y#+ltGSGY#;g??slv#Wi!eM+vKdWlXM76 zIB$ToeRIm2wEgQylNmJ%_8tGSc$Lb7O+n%&ShHHc=dBPTierSR;@F0VL+>ubm9iSY zflkt>*0-k6(f4S@mU*(C=#M8Q_I(L!W~;!Diq@{b>mIxdsvBG`Ils||mfC#!tUFpi z6@~Oj=!PVCkH7S_KLx|h{$D7QYXuB@zu}|&Y6IgES3xjnFdAnt^^hqi^Ok0rf}jzT zW&01qIG6PA*{JTsG+_J<$G~omTtSNUn`2DAUxWtlN(^dd7;gr!Z!t36@vW==)OqEN z46HJwkZe}w;+%t>?s0PUG|CEtB$c;@-pJ!%jhI-SEi;~temx(m{K%dvZv@(|qQQ+= zv;xK!H$jsur=iM5u1X)Q9MT@3>cpg~OHv}nY~q&qW)~-BHBX^QaX$Pg!ogaNm5Ka^ zZQ>@ZV*F!nMGSCP$@w3gJ^l|?86o5_Qz>pMgnGc%yBn|-7HCseeVWqhq?lz{Ceq9U zkH*z*VDBKxO}(l*s*z@r@V&Ae)`3yH&4o0KYl;4px2?W1XlrS7Wx z1W8-bTADDo^cpIYtpyDv4{;$SVe|9Il^q)LOp4qeNz`;hl##GVe<>|g678)RgbXQc z%0s**O6;pJE*+rvi|i5s7?S!>G}!_3e+pC;$#TWLmPBDQx(R_2fn5qRaK8mxkY3)b zUWX*d-R-{rc_h(EM7WkdKqV3;z3RueYcmDuKEWDKTv1s4_f?Z8-lb9H>`8VRwz&kI z*Z}U6Y+S(f<{vjuDW-8NA=!$@Yi=1-*sB_+wm{xh^9drkdK6i&Uvv9?U4!EvUB~i< zWGfu5l;{y=HVYVMfk&ib#OR?ETFDDm9^u3$GT=Xy{Y8l*so?u$8S0Ism8`;-zX<1S z#oXX3y~&uP-SCy1)fc$Op7CS_mDHRBC66IC;OFd82=-#;qDSNdX`u<-Bf!8TT!YrJ zITEwaA0%j5$^Z4auSSb2i=FlQ6Poh0yuA7kS41P~BnLB{<}Vx8NeJKnevcxp)teqR9-dBx%_8>0+1Kz) zrK34_9D2pgd3B%`>;>2^ej;ofdqUH2nB_00Ax+)*o0ZKtKxSiE^6uC<3u#1bDMh<~ zz@@738Uho$R%^8VD4&#b`e&F$>|_a{3!5d|@Gc0hHxYaXf;dEgJ zerAm3MvfS_ff~JlYE*Kt@<9fmtTrH7kv6OBLjxx2oSb|lv$O5xw3tDmh_k#Wtl!BD$;$HQS6Sx1{`BKpWd#7?>T*qvwoRJStKi?GbIo1@riFCkEXWVX6G_{vmaZA?e2piE-0~~%h zRg|LA{fiTQQ*mUJh@|Bh87B}4fMVKVl>r=@du*bCX2elZiR@ZId=Ek9=~o*FC67Ii z6P*mB3*~iT8|`wMr|3tpHD;14LqHQ*D$EK5M50h~{_32hMhm4gNIP3^7U78uZweH& zG%s6&x}l4y0aKk;I>Iy=nZ8o!+ZF{0oPS9t28h-m*EqojxB3e#U>w4+omGmQuZ`Wt65sYYokFq zpYl<6eaVMj4hlUTL0q7nNLVx6im4$Dbj^R;L%XQ}2E_yQ!y-Mn``P#RcozP@;)$(i zUvP3ABNJKwuc6VrJA9KOoJQE4>jP38PdlU3sy6C5+l#*3h7c!YskfJh@K%R}gv41? z>(0;}=Tcj$m9yWxRY};mV>f(RdOzUe0)E|`wL9Ki`7$n1PPJ+PTBXR;tD9Rx(okoW zQQy9`Ly<>Grb#nEB|;!`oS)3>DJxuV0tfUBJMoR{sVosmcKP~`?PVA!{axd5DI_X$O{q^lzmF> zps|m@3S*C0zZl1g{fWYs@V1W*@ph+A2jI2oskwctATsdL9d0j9eiUmR$77#!Ixq_< z@Vw1sZ=d<|QGfdu^M$b8At(g6hY_~VytpEAI z)8(jEOfxV*B{vU#S-EYI?+4@eS^S)Fq#sFGTnq*iR#1C2&UWwG6%M$$5Mya)%z+E6 zmb?lv>~aB1Q4FQKq0pD;gt(#A*8?wka1g>h5agS7`{A(*C#DL>#UNvrXsPi)eN|91Z!6p1PS8(&#TrmQpsS!zz9Du%;LD&QnAtJZH(FwYF`KLR<%1*Y@NBm& zOI?Sn)(t+7&u+(?{LW8x)Cre#p*@*~2PH#)$dw{;VvBNr~gyT0}I!*lc=y5ZY z=dOsKWqh({v;dSQ4_OD72k?5E)xF-O=n3c>`9ghX3~{UvQE?$maM)b%uDGn93Wu}Yn?2NZx7({jlad7r zBBP=kCmF1#dg!?}G+|jFyC#0a-fKdNsCcS{h9V-bLI9bur+;Hjy{~x;$pQe{Lhs!=iaZP7CnmJO_(L8lr@CM9hhz$9uI^6AgFsm#c$m!HFT0u}53XC0 z8yKBI&d~$O3?ur4slzip_ll$X!1C=mVx|o=LD{eQ+TPwXg0<`=rBc@o%WRlR4y2NP zx(Jius+6P5KQSD^wgYYgBcwUUe{(nzL{=EW5rNAL2TwESxcfi0oaER9E0Z<*#U_R< z18}9c7uj{e)0ESqQ-s}`FKf1|j1ouil?jaxg6-HyvQaZ9?z|mPQY*c&mupy#6sqwy zKcR}e=m8eySNaw-Ss`6E1JB-exW7`_0((kF-NjlfN4hmyI*Q+(4S17O8sHbmc&oi> zqQIMU1_pIysWpbdoOmtad9&{`uKqE-Ne@ znDmXyEf~YDu=M_X)U@K@7m66xc>Ao=AZU>bO@CQ98BYIMbSrcKavaU`6@CaB?LR>4 z6NOnM&6q5_Xnq2wcH4hi7|X2`!kW3y*|}NuQ)% zALUQ#+B_p7)=Y31d;35iy{KrXo_2Sy_Zi0aFA<8@(5-VYp5xPm?$%hoCemu9&-oAn zVeA+La`OVA?BK%HkN+5^CIq5o)m8&Oz2T4(9f#d(FQl}Gm7Hf{S*Ie{U!XxilF%^F z-~{b%-pC0+K>m6DZ=wh1{}4TrfB#k?m#*>cL46iRiS;~Lg#~Yks*SX>PmYOsZO1{L zHSA$+I;Fy5ftQ<^{(AFHE}yJOOy=4OGv$*lSEZvYR`#s;c+LIx^xAmg1$@0V1pvz? zu2y{f`{RzG*0AGieY|Cjfg?ZT{maj%*Y(T&Jzy^X z$KHS7em!kC?)f>*$NK#8YUJbe$=3On4H!;(A39&STg}rhyg&abL;Ci-1ECMWpfL1>xww?b75ffe9zYLyBpR` zM^91kIH)>^(c#SR>&YKCevMo2_*oxMf}YvVjW4G9%Dgl`GwfC0KIMChB;>nZ^COCg z0C=BYfr@K=-T#O!>2{0~7C!!b-QQ0eF8kMC@VQh($3U>)T=Xt^5q&!K*eu$B^x} z?K^Vyu>o5H3F*W%orXB|oW9h_oXr_`aek6L=9uhZD4uRZFX4{$+*UuaJ^m6LugKqc z6Rx~KA|m;!0|UOi$w0XcPZHvBw;?lGJL-@M2&`BZLW>c&|2mB z^3h(GHOxh zi_I!!uJnujm{x~y%`PF@9f8<0TK}*%DBt7&bHrR)zG;Qv$48&ablL6J$VXzubKhr` zxm620jGl|n_Q&!U({JKSePR2}BzUe?Zk>)jpr4))`nXBhPXBltPpANq{}rWv@3L>G zLP2nE+xf#g5HPndoxUAC@>m>;OE<2Z`&^`s^&P3#KMXgZc=`275Vduk3zdCThkgV= zjbDDsKLURokaXg;sB`N{E+x}ekoczx;nsiCitb{a>CwVodMdFnBS?0}@=YnJiL?F* zTvi$!-ixPR9U<5lH_haK9D`jrN@0G(>2*a(Rf?8v#>_Tj9;Y~EvSq|fOJAp)VZ3)f zcg^@5{i$ioS{{>D(s38cfax%`SsMs|ttIYJDF)+SOQb9cu;`3{v$8v(p9Xe&w$|Kt z+haN*mZ_}|lT1KYbrGg}Cr}bLbx&r?^D?%|B4Gm8$tx1|Lv~ir?5DrUcJ~5YmdhEx zIVMUOzH9V9MVAQ7`d+o?UxTw}Bdb=U_|V|BbTd>YX;@!ZFqS($^EW=bom2y4-wD$Cd`WASa$afT37F<&B~iFDlUo-Y>zVK4uvvU5 zYy}H6)c;X}uCXLIpbQzqcMgflXX#lj$=5v3v7;)3H@K0C&9uUey>|m@CcZ0T^GjQ6 z$vRr7o!L%f~3OilE&7{tT^vMqSM1$TN{<;=49OL@57&cQhk$1r=Oq!t0=LT zN>Dlnyily`g>vaAzKBLGBW#e>T2otm>Oox)yq~W-H-BG*O`bgKb*|d`le}WpDNDM# zIu(A9u@P~AmFiJnOUMIK%o0w8Jg-}J&Q@w=*7pTq3t?TL>uRQY)t8+XDXT@vr5c4- z0qq*fQIx047VmkN8a&I#o?=aOKG|MKg+cLh_GZn_Ne;X03V!oqOecxgYBe52e7)zt zp?8lpN>rD-mnozui~iom)fQm%SM`J*8!FzEW0{m(wXx-#`UwGrt|7O1;ftT2ZyyUy zK_)CXyOBw-Z`z{41F;Eun0j(}VaTe66s|?}kdk&mg)%6(VX`Au2qU;Z^VOEXy=3K( z+^kg6RfDtq?*q;iP~)T{$jqfxTjM6*(kZK?cI5!X*j#Qc;_hh^qDW0phrCh9IkQh}@2Fl}x_ zOWsNq#MFmm75eGhE9y@#Bs~b@M|dF9V~4aN9()#zzwRZeLbH-Hy7LSJOC(7C-kFs1 zINDm>4ZF9;W?iquH|1vY9t~qE{ zx#ejOxQp%*HC%g~qzRuOR4zM*D(j&m>gRHZ+h7+~q%g8)%%=L}Hwq+>QgL{QG)??| zZ7_mI5Dv1%pd}UvKD)zG&?;jc*XVt)Wyg015l%7AltDIr&Q3!q91tDq(X{38;vG&L zZ#-6E$}s>*|71?fBgXU$^wJ!)#v46Q(Cw>H1i>uu;17hUX~&mjY74F!Zu(+w^8ddGYGQ=*jc*y|0m zuZqr8V|^2;S(5CN^z%`h%O#;v{8yE_CxhIPY}H0JL85#i0nKuM~%lh}7Y2`Rg``ZUFvj>+zF z0ts-^(J;q15t`JHG*YdJaHn?Kcr|d@?1MvFs5Hx@ZTrIFNTzet)X+=Du-T8ve06D~ z_9}4Os!o>Li$*!Rq}^(l*FwFL?@X=`uhM4J%GXCoScJjMEh>M^ca~f|QZrxKX}WXz zYT-{G%r+--s{f&Ip*=7tFc%AgeKhvE5D(Pshn6#hj#j%$7b{2+%V8E0O2hu1jYlN) zy_1eeDwUH-)o5m-qsvENqrB%K1z$sz>wkE)3z{Dpl_F>eU&#=F*3Ead`FFH97rQAe zM@SpF{h7^RcvcSKosC}&YC5>&t4cpm5q6v4`!bm#S0O+#abL2wa-oxr^0xR777?&0 zXL3^kMhQU%ZsqXKMi~^aLH5s&iIFYXK(9p4K zF3F8&d0d+gUAOrM7FASv0tlXyXJb{#S`HgHid^HuKViRECzjhL<9uw3@zruBKMK@iEG$_F=8~rtl#UJ?tH-Ezl z^Eb!T^T69E6!Mxmou^=D9-HQd$D>BE*GR#iTN?dVNqLw^uDJneekh}7D)v`NN@Z6% zprbN6Fl~ZGW(db^;Q}p64mH*|kYE%)cFMdY=^Jm?LuLE_D$`E~8PWfQsd5>) z>G@K>w1Mau*7v}J1q3VhmPg{hZ;h{{W<6sNtJ#?7)Q3G~JosscErxj5N@R%nV5JSQpa zv1k?k={E!rGFLip@$E{G%U+j3u;I|BwMNo=kp0=)y>e?+D7G|GZYnR{jwqtnV6k+d<8 zcWrbuk^d`v(WcR*>%!|5x5MK4C5@~kYf)gWZs{N*hutDIDI+;2El-mFyOqE#E>J1WZ=@dLN)qja zBOkI*+Zj%Vq+lzXzMAS!W1SH=5mnuMNYepFczlMc4lLo={CHzHgjJ7&NmA6bge#In z4p!@qLR)Qwkx&(`gVM$NaS6K5S?A#`t&U6+tp$MHhx6$)LmtqSC|1E<5e%X6EIn!8 zm@68Cp^nKEhs=|z!D*2XvvOUh4C2*jAIB70#qy|ak-~caSsGI!95Z~Ab|OHkNG$wF z7@$NmxAKti&7n!&X=cgv6||^@gtuEy@lu6kab>bK&x7sVeG=7kQKrnyIXdEEUDpop zF$E&IK#m5LtfQ;V=Lv^cprZe3ma>=dT9QL)*EVNE2g-wVhAVpXLDYnw&{3CH;f>G% z-DEH6l^NnPp5W<tk@Qpc?pZ=xkyCTctWTjnJ|Ob?YB{l~JNV0EMNY}%V71S6Qv;~iPf%3pHSafE1p3+#!f#|k# z%jh2-yGnx<_af*&=32Y*J%K;7mpo^fVG#`m@#A*1G+MVA_iCQx z*?CB-I&|2Y(0h7K^d#1B6E3tS8UVjnj_ST2YWJJRQ4N9n3&#bRdrF$vhK1d9x3b5Y zsDvWHQKesA!>pm0a?=1?P>~Nz2zD`yP;OS(?4Ymw7j*wPYk^}!!bR^m6bvXD=u1ywCQNV@2XAl&?;*it zX=}UbqJ2wQoN*FXzP0;8mNz?*_5$_50X1ATN|Ih8f=%?DCCmq~jg0h+PomR^(yLfL zn8L40SXZ~w1QOl%a}>nF|IQx;k+K=W0JbyQ=Rym);*W}{ialsOn+C>SL5G}ne2414 zXuVw`{UB#tf3dhal6uYD{ilZ6nZZ02<{FHBkcA%`Tm+&QE_7$nN|-tEuYG7HlLnbHgylYV`n{SLO0FWMAyljygcfRiuBixVS+u z+(hK>OrwFas~@1!+yw-rBym#1xqmH6T1l2U%rp+lT?Cfl_h$SJ0I$a1<)euO)x3vb1mNTlEF3jca2wc*|~A{-Fn{s zgtAY8b7)S5A);V)e!_1H3ZH$7UJ=3?_{R?eYdn~W)daDpL=iv{>z`=_A$O6`-(}AF z>D|KRTYC|iJPPh8nS)tQaGD6at4a+mXpylkW-WDa8NBT-mJI4SDyWO5jxsukt@WUoY4j8h(VKg0O5s0`Gj^v1^x<>gROUVjS_$5h0 zNZdU9=^*xLy0ILP#-tuF6e|j|{l?e(%a*#krLvY)l2+>mBz=emo*H@(A$^GMC*rzv zy#Q6}NP_7~Odn!hHl3`itCLlxfg=``H(re5CB~4aGzM^?xclE{UQh%_eR_l~f<9$q z_N3qq(QqbfI!O!@@0iztI6`~$6J5UldGCJ3gP3O<{ze_mXPq31H7jE4Iq^vFGmLw2 z5B|SnGuSxCDLg0k$(DOV4pp5I8jB!=Hv5Q#w-9XAljy!YL@Zz; zalN9k%^cA7mnH#eYx#+9%VFdkXCb7`HwJ>VNJH=9ahsdYW+~j~NxMX;VhFV{v76I~ zc7qb(rA7>|=4Y(MzVU^UrRZ7U3j^!K{p>44g(46_PW8uZ)xMFT(2Ftqmfc^fVG$Em z=xSIjz$JAKHm4*8N%xPUK_A>F$GkBL{?Cw;zK@ZF;4PYJZM6iJ3^Gkb7$drPnlrGW zhGB2oycVJ3;VCr4(f{g6Ml~``%iUkxYn3%s6UOJg$n8iC6XYLLOT~Fv#`_C&bWsWq zQUGvy+5f!Lx_Y`m$_N6sU^pcZalJ~@JrT^YE2pIY7V#^_;b5;0!lZE{X+GJ+4VN~s zZ}i#JgVj`W?9;A6_2thR7ki^El-|KFx!pH3^`L99f{OXL+jOTN2!F=;LSCfkE;$>7 zgM;ENlhR043O|(ti4%5iv+8Cj=`)a>qyU^$U#&obIV@8D7z7*rf}eLu6hoGE_xlzs zY-VH`Z|MRuiCODZK{FOqa7iBivWtI{^F^RSdbI&gC35Jjg>rsa8}`CtClzVu6N77zL)# z5dNDjgp&+R92CQKzxyO7`9iRUk-1d}@c)2{u!6@fzk|y#n>i{%A)34nUhE_qLOMz? zdEez$-Zj+FYKQ0ar*f4{7?#N_V@@!$**U@%3w;U+!VghUH zTi(kjK;08tqw~c>=^pfrVCQp#fTCV2SWKZsk~zN!&{PSv^-!LQmIv%;+6FB$N}(W` z{0TDT7YSByxL;VFFLH7ewLfEh1<{(L(idsUzXa{;W4FHn(k+0;A~ZPYeTt zuLFqhm_GU~@U9v{-PG4gvmZGkSVl&Kz6Z7{{ zi5}axfv_95iEg@CFb-0()LSiPj)`KZBo-~|3gNH*;$T#Z$sXuGRlMtnp>jYxF3!~6 zK`)MrBcN&m8wFvraK>;v0W4_DCgKZY?X@t5-8FPk0ROx-OV{ud4gIGdyk!E}TRAbw z!mWeI9Zm2_`eOOMz$0rFF2RRJEk$P>M_}KcfhY5)kZcr0U8PUei zc`~n&;>2TzGb7ml)zvqEN7i)f#{-w+2D4u!}zA6<^CRDArph#^cS>O67cKN^jU}ye9u4_zGomLuWjEm z5N=OtzF3xlm-$LbQBsx5OGI~#TaaU&Z-d7qQG6gWTe0|;m)#P@ zFiUQn9?OMrJAH+B#$iDQ+yo;)4rFLuf9K4-@!fbQq&n43RN8l)MFRm7or{qZjf0bO za@;EN-hD@NKEGW0$@qRbIn5cP^Uah$7j9Lb&v~I@@X^yL_Z`MV(zCmwuE5{5>^KAt zj+%$YH>5YUfN~&?Ay^j7$r)p@kCgm{w$8!Na@KN<%U{dEF-w9;ciLTb6Xyo@p_sp3 zkU+Yu<9>~f6G&{CauNp=01^r$jxofr&?DgnMIDvTpqpkQdh&OGUKekpP~px3unpQ6W`O(1A1i71X@6)M2EfyXbQk2Z`e5mUZK z*3~srm7gMiVO~l1|Ex+wS=^70HEbD?o-xe>HL$*|XYy|LoAfVEPxN__DW+xESV-jX zJ|+;V2au~?oIE~!F_1*bqMRcaU60yC|n*uU=^?(_bfmXd5U1>J8M2w z;CBotTK@7rUwD7$eB)eijqV)Ey+>_y#*eA~#3YBT#_c@`cMyFOr5-`dKYgUS)S5(i zCX#=DtvPE@iP`vgcYO2l^?iH&*m<$pbMU?LJ;o5cTlzwwo34H?UmJq`c)!3$PzTWb z-NO8}qsOmutu^BGUO`JpA07QRw9ESr>WI9xb#w*jvF_UFnbZRSp6PuJv8FrRefnlj zItZ9Q=iN2BdV2rzb+NPg=6&?S^0@PO_d60vY-46_5nS%}_B&F4Huls>LBdnwhpml& zbB}mn00ChqGNNGu82_``sJ`yFCV}L$Rq+9t{1fr7wT1+92WA`y90y082KQKxi8Mx_ z0yq-&m}^4qR!(FP%a7Ilq2M)f-UTx`J(dr*ttak_aAS`Ie25N{v<@)@hYmReM9`1B z($(TxD-UG6$VQvZC3(0U`jw@p=JANVhJ&-5B3^^t}Ya zb*^m2MIi`&W2mn0q(qY`{e>H^afYoO0U2br7gVE@cTuJ+N@698??$3et?b9*&yvbnXAw{-y8zEcqDq%8Z7y@-9rEEwxy0Tog; z1!VX)jn}GvV52`{j0KMMLh>oMLk9dMv&bP~IU%aOPhgo*!7h{4Z5G+~)Rvm1iyhc8 z*J{rrVmsEuKtHTGw#2YC&fY0aIkJS6J$|d>&P=yif~VFU;B+*1qUoe)fDg zJ3IkAJQ#ynuL%HQJ_ZAgv@17tSDyF?)@NvXh-sC_jWeZo*37TC;gq(lWCdmDVYfZR z7r$)wQ>{H@|3vklIxp>t&P&~;_RYVp(9)ouHRI_6U#!FkBs1phEyr!V1mc@wVVZ2-L_~_|hf`%z6{>AAikDP1JTVn&RhvMBJB`vii&?Rm5A8LcoEW{5*20&25CGS} zX!XxvWd!UdvZi`WxuDs+%c!72Mud@M5@UBq8}pX}?L9?23TF~JE`lta)S2Dar#D+C zhMp+f=-8=0d6z6wyn(GocLUHmXpaykg_klBGq+mEEj*6&LSM}&%TUPqno$^w+nDPZ zc@|ufxA?G)N!_RhDJCwD#_)z0Ir>EVv|f~b3VAv;4|Y5paIa_oY=l9WQ#>V#z4`D# zD)684fA(HoGuO0I90V&vXy;YN;i||uBK67gmJjx8J7L}H!7{{Mf_umAI%r9^$o?O{zTC7TcoI8>q^q0aPPIaSU?HkMTGGOE{ zXp^dxiK0)fBhw5N5l5r2<4yEe+J_O-1}Oe4Mzz3$QI;Uv29~0x<5mUpYBMfm4?{IQ zBEowcWRnV)IIH2(_RsdgtpjAW=wtkB4*8{dM}uiJ(`pU5fIWX@E?mYZ)Kk(7o~Pmj z_s3u6G(1F196O~ODVobGxsb4H}&k? zKE+%oA6}SwVwVTN68j8*{_xrQT@$FiE_8X{uonrjbX2esj+QuwbG1lKD!Sn( zo^0BWU>unbg;6jClA94+gchL;Zcc5r(O@K77b^W+b_5BRbc52zrr3;X@l_d<4BqVT zj|)jM;db7~UT+7|tONK_9cx;vG!fc3hw}`D29m_$7`Oq<3q~t?(=T4Gp$q~f z3EXWbZjxC%Bqf|8ha-x)WV+5tmiWxpFip@eZ32`>Pe2ZI=2fx|KnRHd>7PUrD zFxVoc509YJ9`AUBg}Q-~%Gn0?F_-Gy$j!wV)9hZgU1Ik%U6)%mb$H-EzJ`mv_Yg2+ zp=MvsSU^D2CjarQ;rPE4DoVKR3BFrlABZ$w_*lQ3m5LR01};&-OHL*nS3~-%2&N$d zaWb*;IQ!g9r)#%TK$YW8t`%N=X$frkB@NY<+#qjD%)iO{A{8EiHs@x?^2j z(&XBz>0Rdb`2P7gaO9zMb<^Fl&FR_Tsme(qaQ)Kk0bG9i++Te?e#S0M*wt>OOtj)j zxO;xoyfw6ARex<6XHyFBn}a#DXi@7q4yy5EK9>GfRp^7Yc#^+=SAg!*8Ju72)K zeJs=@$ah;48@af-0XpB?IzB!eUhYeRx@ZV&|1x~8*gehEimmNkkniH#>H5BXc-VJ( zdWVGR0j>xxw>}eu+}!Z(Do<8QmnNoa5!0S>8GGAV8xH7Wo=4u+QtF0XQ3pcVz313AO_nXQ>~ zZ>dWJ-0DkMg&sY~Y$$5Dz3!aiS9ahR>PUb;vTkmKH|R?5d=aZ}A6Hnn)#RM2r0K^p zfLj^!fh4v`^MNe3cT5|OeE8A|!3srJuaX}y+%ZmTb=NZFCvt}Yu1=CTzWMNKO*^PI zZ6)wu!Z>^jAsw!o2w5q@r3Zxzj{8l=WGZY>iFK~=)&`g^1=jhM-JnZS&YoqO;j6ge z%bg0@@1O)5k^`qOIMN^%Zd6*slf?vYeee~>f>(dtv>U)+y%maW)4{<30ESH3f^Jq!f>Yu!LfvTjy#g7Cau zCn~PimcxF#=Ird2McLqKS+d-jE7y%$J=2t@#60GVm8y|tSX<9C-cZEJ1K{d}a~K=W zm&x{wrLjB9Z+(zxa%D^ZL&h{Nq%I;yPj6Gi2A$9QIDZN+YEGf6iCt<4H^5_{@B>{T z$5b@_Xn#_tjKg-_=p?j_4iI)$G3C;3JJJMAzl@|?Sxo9%o+HI;I8qcC*tE)+Wc}UE z^Zh$N8azmB@K(c#E00XO09JCS*bB?08AhfYzj1^av*u1*A0w~ZGebUI$e*O;gm{*u z;LhZm6DXm?f4TSCqtp_W-65U93m1Tk*yC$<8-!_RG5?d^8pPjGjt|Xn(Cwz3w}7KP zf{ITfI_P{NsqrS?1rnJB239c|j}*_aYzne*SkG|+tCG|RFJ}Qr@d8l}!erqsfekBV zybkFTEaO+1w=mIL|6~Cj6_n8pVQq&x1gYm^O1jjmmgzGYS-`3U7?bW{!ys_kr3F92 zWNJo(;>^Z?&e;W{H!Pg-5}3(B8j6&2vAsU>iET5wOm$goYuYN|QMw>J)vzJ6!W+ht zg*V!cn6M)A8aM(N+5-1C{gIIpDG`lxB*!cRQElXw+(mlWF!0ixX~{p0N{&koK1o+| z({f0%awK(AB;yYiGVE26w%FCIZ?><`4ed;e3ugml81^)VCrC{tpe5ZX0%ow!%M;i_ zdlL){YSWmf2oq$d;*&)ELHTJLz`9F}yN*JDFG?aQf5ri-$)ido6-+eEfm%iwyvlakN&;_wB15WMF@%RWUx?``BtsA{Y&HMaA(R z8Kx###9tQ*qB1)pU~pbcRVI}kxYII(fS)G!_ZD*bsO^y^X8K#F7~QnvY!<4J^%wCp zfDe*VcsC0m<7)a;DCvo+QjS{>1ge+p6;im$?!-s-~p2-V@%gxh_X@0?`Nrz9u zys+-@E4&vr4jV6brYjB9wOeFKVvLMVH>uxn77a{$X!UO~hJ4LL->b>LfnK zGST+2OvdiuzMOoBfM-O~^ zI$<{*)D*OqZ$&#qJ#Qk8YafOolb}%KIq-vyd_7NCk~fzIv$pVFdEYJ!9mQmBOQxSWaLF6=VeFVDNP0m5@fJuR26-a}r%0Wn068YTLJm9pQ=Oa=)X zKhbRffeFvNv#K$;OEX3?Y$3qA5@m{gYig%2Zi9k1{x%ss0hRZ-afy3u>Zw+gd13;H zw;r}ZHtI)dA$GWmwBO@0Es&>FMWGJPsfP13LyL2O!yZwE2pAejf%9}I3SC2MCSzWI zzZ|WtgYErI_W{#6U-(Chp@sR6#(T60|HTB+PVWo1>9V(96^UTSfI0?Q@pTc)$qU*n z^jf7=C2CN&7Zy=Rhk3_ufR>Kv0LTsiLfRuKFJ%T*JI~pu!m5>`-IVQG(olPOza2`m z0VMs$+`AdGnT)UB4(m{y`{-^_SVBOgd*}$bB&DT;=+)i!ZXgVQ(+k7kwpScapS%|9 zfC0$I4njDyt|M48GHnH=Q7_I#csyqpkC6sKbCE^FloU_jKWwj|Y~LBqZC zoWT0%C_5t^jE}sMRW+$80Gu6g)Y}dlcgEotf<@QNQ%(-opRc21ot08KK+9=WGuB8n zq5?)IJrPhinjvaDLU;de!MZ(Pn@U}c$v{!7aWoSpdRG{4@ToC$;F58($k=5zhvJtQTYdZ*uVK7V-h+gbSp@|RChZp!M& zHvI`g6bG`)C>q*4zRjQV-kN>yYI^$Oq~`8030D@k|V-7F<%zN zY;U7zu8-rabtzOVkZ3 z76x)bwQ=-5yr!Ndebg6IQ7X^qi$xGiBZ`IgZmKncHi0}_Mi2&Cd$dCEwClS4pxl7K z$9(ZQVL8BT6_Zv6a9emg%Fi&Isitv%=Ztj&&sZV+0zd3in1;a`Bal z!6|WLPI(qFyuMuD&i(Mf>~)O+pPa)!lON&ym$7$Fg4|v;Afn-IWa{}Hq^VUZ6z*UG z<@Bc%8l%Q;h}CbL=MW^Q3zMFM!l!{SW2AkOl}kc|jVIwiEkX$a+A}*f@yOR_^Izl( zG_1{#hD4ANYgF5L-CRi@Fm>n=^vxKdRUJaw8x_P{C&>hUhQFban_KgfVVQIn<$k7h zU-;#@fbNM70yK5jZVDI-ha+*@ejmbyq0;n#&yf?fLaaZ;tt*Q-gp8rTZ1EFZ=7gv{ z7`n@;6}Ka&Ap8(7W``2tRuxU9L0uGGBhF3^kKE9}v719naK08}jtDk8HuevD6Y1E& z<65g1Fg-4lYYLUafL>C*4OOp3+Sh0qwC2_a?Jy0z2T0TT%VsFFpzI`9BhFXJ)TTGm ziwF>-2s6jK65F1ss{YLLKSO1k5sH-HoePboq<%t=c|R4?4s;-nk|+C91pho_Mv30P zwCeC!q8diq1+$XlBFj|_g20Hh6=3lhJ;A?Dm^=L2COi^q_-}rh5kB$pkKuY^$68`_ ze{n=GLVz$0WC7E8jTF{wwFcOiW_RfU;@Be@cPlo{db zvZxdUYK=g>Z&y=MSC+GqIq3usLpSD8j!3*0m~LliDEvu}qosiYXw}gqHTkLRj?zl& z6L5^t9@W4YXQNy!ZHx~iu$V53+1`L*{>Ek+0kKbFDpZH+1}n{6Unn|pZ+CmX&rc3?bTr$PTc*)j0Je$av`D>PTbog6u?yGBlR{#Vd5AE^)|>ZoAolFin9o@ z-z5?X0>;JWUg$FQ?4FnUOCz3pac{Hi87gnhPAJI5a5aOB0E;fv z!eSHA1O0B<9>J>~kp0iy4EgGj9eX@(3S%1PRBe3q0v!$5LBSF}D4a#55OtUt+}*U_ z;57mtu4;f9R)hP$LcBJfw$_P%V^OpJPL#2^({NZ+XPq&oEos|`Sdq%RN1qO_>Y-Bi zLo@iIY`?5M%?!9*J|XHi3$h zm4*OcJw|TDpMh{vY?&X$VkpC!d8}g^So%?49;^zsnuh7ytn<3$S`1ka39x8j8Apw* z-{}ghC$fA;lL!81o&XYF9$!HJX)3zcOFQ?G_M?^JC2V3i?FX~CjH};HGb8Kf8)bvq zDHntIi+@w1a)AZmQwJ@knFv8f2`~BYNJCjz;-IWV?F{cl>61K*NsQ-F*^T`?iyz-n z2{HcXvBZ86*Oy6YBxOad0NsU@a5#OPvmC$^g@ikUE5J_yZ*#}@Gfg7%LgIl zrZC<*_&N}j0z=3xSOvz70;8$u{{b*j-~oeTRu|6!kA9C=7D{*bdY!iG*PwlOr$x#3BW3I)5Y*7G=!-6F zs3HC{SioIz@5|3Tk|s5^<$j4e)Y#T2WsvbdxXJU>d5Fm0sF=w67VX7QQ$Y%E$ZX5YLmx+o{pXe-4c#GK0q!WQfjc^_p{a2G)W$N( zguy5UaIpiN*Lq9+Pz^uMb$%`8Kfw`F)8^oZax9k|2&f97W<@|xpM#MZgQEr=)OchH z32c@yh%@%*_Z$^mwO`=0gS@-Jv3HbQp%#v|tBhwLiT3*RUr%NTmt)TEQa0dRS}Ori z4lh8Pj!j|A0drGmv&5Nr0+F7rn@{m~_z?W<4k>7}D0v7#njpffXtTTj&(1=H9+xi_ zK|Iek_y6*L0oSMIUF1cFVe{bQ!M4fOK8?1 zCJFt-1+&usStIf?4~cjy+(9N1m3>q2E>D|*F#0I&d z2-`W>{l_?lX-5-(K+zzLfTZUe;W+F6+!Q?xEeAU^7*K{RDL9(zQ=Z*3OB3y*6RFzC z4tW+35i%vldxneDgTx3 zn>6nE868Qz-e)$V-D@qCK<=Iqnk23fpX;^LFMdI zqv3Lrv(6{qF@g$kKZIC$4y#GzA*p#1aqJ*Or$q|TlJ{#)n5L0-a)~J9#8d}p@$jS# zxwpkvEw&pV&kW;e!$vyt7$u}y{7!(g-xQFvt<)l{vGaEiXa!0Ki9#j!?2l$Zqn8p5 zFIsA&xt=FT)#R0*YP7Vpfqn^RLfyEw_j(hecLymjMPh9%h_jX9wDoIqpNdScbN4`k z$#%c@-+`8=OzWw3#E*-9w6q17kk~S~F82_Fc)}#x@NnRSLk5=x=Nyx9Y;NSqkwr!- z&LuFE4YRDc`P!<_L)iBr(TIT{#;m~YXl!xZ$1GOkABM(sQKA=iY7a8-gdqPo65XoX zmWnfLXA?@0g=XIm=ZQvE43hF&OG={@A``GhCij6#1_C%$FWkjo4)Fs5^enOlJOPfD z8fCGCN+vo_p0MqU)iV%)2F0BDVN>6n)3a|!0)n+2t#F%eTaJ5JV9Vf zJPr!9x|0Ozs0bZmkx_MeA2_x@t8j=L12121qTS6B!kjakskX->(9G3xwpDoVhxDALEK*87=8JOr6ns*HUsJ+I4kpxI zrZB&$5-PWb*cAX_C^0rmb~mxq-u|GI8BO%^e}*v8wgW%JrjI}FrdAHdrY62Q&{wiU z53=7~VZjjTPtWL)ymoAID$Q=PG1ben_0;U_D#h>C*}cccQ1ncI_4~hR5-cA~eFZ6m zE{AR}o{qAQGLH@>hCX_)H;L_gD^tC^Lqpy%5)nIRDpN^YQ#0RMH?!@`zgA!fc)Yz+ zw)hEqDh@6_mp|!-ZF<8^?g2oFNN8v<8*&60so+3BoT&fVx8VF|-y%zW-FBS=$wyEB zOK?`{i3o$ffG*^spjm%EK)dDSl8>4R4>q2*x`e*uO*$RpGw6Z#ZX|1Pbbmzu5Ae zdCWi-P6Xb1*AZ#ay}C2&RFY!N9*=0pIIw=53W*qd~{dzAM}3=T1TZ4 zAlIU(10cdoMLK2++hWWTnEBYJo_A(q=x2TM!*#TgMUr`WOLXdS%Cn6 zmUhB7mzT<$KsvtH8~h#C~^V@P58r zyiwea3~G!8iPO14mrRl@mQou3SS)b(Ew|5w3{a9Y-w%2Fg23?0jwfKI6EG^)^o>@@ zjFeEHnXYvRcsJ+gCwRf~@bz=pW?XUOW$ypYd!m66BFJ@&dqJC`j1V!$8Fs20r z0V{RfPuVCIC6Te@yobDw9D$U^z<$jL&j=e}54gY>M~qH8P)80)AGsEl6hjIjy!H+$ z2TTaD_mN&t-NoE+S{Uq2f`*K$mZmVBZ6q8vjum$ijv&nkVJlnYNYHN_t>h*B6nzIN zltn3-gsikYOv5%dfM{pQterfxve2Ev06Wx{4H6HZz$ye&fPp0ddoyl7(bfn3iFx>z zM6?^s0mb_}Ap2fotVf0J+0ggv8JgHS98fOXr^76V5$~dXTfCX{&BlEdRwhzjl?jhf z#Ny|~?+5yL;}Z$0Y-O*Hz?FrJKqWyBi#%*Ap{+KtZvcdSF8`qtR3sWweoEv81`hlP zEegj~YA=u@sfQPH3oDknFPQG)5qJ1SggB0fHWUsO(EGRMMi7H%Cb0dttw8fh2Y_Y7 z&4f*_@``3u&inmqu=j*#d*IOL+~U65MjL?x;_=3&GhmjGvId1^a7j2TBzv|B@A#qH zg8_pU6AmKWg!CR{p9Hf7<@o+H#fzbHB1X1jVb*L?6in6M(?DVpM)noPCreW-JO?yP zaLx~PMiE20R?k}hy=NhGXbB`+a#&b;f@quNB5Ol`fT zRD4$9!kMnW@>55)%oYtP2w>UP8ZDjc7C_%r+=sl=&fHmuitTLYY6o4mAWK(*Zz;~M zE+<9_&jY3z?%hGX;^h;wA!Abs$g<7L*!`2o`UYfp3YGLCusvu_X79Z60eF_5zzVn+ z>LR@U*nEszI#CR$HqBcu#b~NrF8)>Y@u<9#eKvhyJibvz!+Hyy96%GA&Z2H^+))ts zW5Z462O8=L-DzomcVdHqqlB9RDf}gED@0Hwz?^5A)TImO#hy)3eD-i(VvT(*(&I_U z&A&&2Ny>R}mhQ3T%|5lM7XbY_GG>%dAI7!n66{(UqUp6(xbpe59rYKFE(S2OK4JUR zyc1IMqUnS;r;Ubo!`vG^apbI}fvq<-0Y<>pde{OSz3rBbxf{_R+IXa-yYf=vqdDM% z5?Tq$5tVpsOcdEwHNjDBV+H@1 z%h@$rAk-4Rt6C+Oc&V{b;GC-4sP~^i8|=+L?X)rKfCU)foGdH6?mwP`3*$=J6TI&V z+af7hu=&|-(YZ8^7Su(0v~iW=CE2mDqH+yAELF{fCJqLk*M^~J!`wury2A=nWh7N6 zMLjwTOrv?2ib-WhxdM?BW!uLA&2~*{LS@I)sx$W3D8aFusT7A z&OO0$8^`cQ5`X$TKKG}^W|7~6A3S!VyCvisqktMk*$db6#2Q#8SA{Li`4CD2w>VsuA$@e%-DUhX8IU94Xb@OgjT z-#knq^1t7|E@<>G)%JD)9v-Ha4j;9j3Cu`rYjk~hzMLL30c|gtpK-IRH8Gj9de9#d z$1$_C`G7`vpNF$1IkFmyl~)MYYCHY^l>}9RN2|}if>-O!E`l%BmRU)fi#|vTQD=0J zHWlc6XFOdb%>~Uxx9Fj1p{kFw4*Yumm`e-63MrjtAZMUvz?}%qq{p*Tu!x1?16%k- z%^isg{2)xsJuS-wNe4~`fTrua%lc3HP5R3)ke3RW3LFZMV~r{iG7~xx+JTOh-$3mn z72`mT5?N+swFgR94@)$x9C8PUX6}0g)cki5=Zx2h?ym({F@eKc>n1Px6MC}u+&VT zW(dZ>UMWr2BQ;YERoHQy-

xbDI87CxU7S+$CTXbRP<6ww&m!Ty0dMr~5NQHuxQq z#hvK10yEcwq=Q=c)A-T&pZi%~b;uf}^mLw;go?0%0-8P>PVjF zyOe3flt3=T!-X{lhmINijxB}c9Q`L!Dk@v*HG>j_`o>JUL^Fw;>R4DMhaLbsV!ln0 zIbJjMFh+vb9nEY}nK>f!P-J*Js^21ogAq^ueWwOvi^ky(hp>y(_j{U4c(&OO+Rotj zIxu5KT^=;-_n`)ZoP~C&Re4L%2lgR$)>i~PHqNs|mPBBt$r0=r*_FSMoJ1hDY@OMP z`$vE!Du4aYDIlY4?dF-u>$u;-v)kAclf5P8rg zw9P90a*%uV>_%dpv=osG2P_22xn94NifVIQ{OR2ndK=z8w{rwM@TtWc4uJ z6!XJZST|b+e2e%VC9z_{@;1p7sx{aFmhA2Y>F{|JnzL|%OJ%4u9Q{rdNv;8>sNDA< zuGAfN9|=dNhdBXSEp_uCGN~X#5SvQ!`G`hTWpfL`)!?;8)18?OZ(LXWev3Z(ja6PF zrW&!4vLd72Sxx{W&?#7RT>&SNHE&zL!?1Tw$c*(0&VV{9=PJ+GrEQ}n&nhXBWvfIB zl^={+M#{x@mGiTCE*(fr< z*pD<6bSAJ1t+bRBv2hqG=7(HX63RtF??u))if~Z;+eOgUoXal-tTIS`A7xqIpk;Z8 z5bOMUxPH&@{AnhJz%sI-zf|F3UI}WJ%m`Vyw!EyGE(D3CBECOYRJ@>RJ^1nEi47*J zEyXeK!X*yqI2eexb;q7xP4L6O60eZ=T91C%7byt;EqC{>MB#y{VQ)Wk)XN18}S5gH;6hIzMNhxp;QAtHK(QQmcsyc6Y zY0V`UPy?tt6q7_OM1}3NQ#|I5=UrG%=(Zwi&`eA{=di}HTI&T{G}R*J<*Lo^bHHI}tGzN!7PakhUyOk30ZxDH$ZHxe) zvZ-O+^lJoffOL#ijlmtIvD}bdSkC>4BpD7^M%cV&&U^Id7*{t^jUOdoT~Wb{$F`I^ zF-26;^q0tFjn}j;nj_yMv*iPHMO~$i$~hF_Y{fVmO~+5CiO9`*2OKKx@3bi|RdN5_ zXX$LiU_E948p1P=U3#d*UxXjRS3a9RFSnXOd2)EL>UeZ8+YHR}6@TD9T~k=0qiY3B z`8ymtgV99`mpbg$9V>1w|J}r25!Ov5fo^yXU$X1j)?K>FE!^%DDT3)2Hd`%74N}5;$d1{oeiD z2f{;DY$~A$b6`1qR@*P72$M9QY!^`=MeQ=kO3Rc2P~FVSnmAE*%o+8Ec|GDD7(If`?YS6jyA&ZaKh|PP zXXT5J(2D;g7}AL$ajA+i^g7R4bJ%0lQ6!Eg^KYYJ1QI>_F~->}9KDC8pT)&Ha+hbE zRnZ)uk{IRwVM^RAx_6Kr4p@A+Q1*8RG9h+p=LGIk3`78_Wpx;?!w-b8+HQ6~OB1?j zqxVleZElNU6mwA|6~QiiC2gpRQqZ~ny@b(d9C)*=-->KTdIwX%Q%BZ!3D7Sefl#vp zYN*1yKljJ=qa67A{k6RyLFD6vB-BzLm3_g-HE}3Dqa z78jvE{leUo2r?tg8E8rSi9W+L^@s64X8{a(;;~C4?dn1?w>IQX{T`KQ=>X*fS{1rO z7{!PBg~_vXzN3P#)S}+%?!G%0ML~Fg+QxoLQ$Nz+0n`wS!?y7K)7WR|D`%dkyY#4X z@x%2yUY@uR>}CL@68IgHk3TG$=(s7dCF+wYc($GOhYdtH12t41edvHcqH`$wK^9AP z)k&Wvy&pn7EONR;dF3-+1`l&!#V`V59cYv<_0|S>tC&6#n1xPAlKB2P)bI=}@(gWE z+B~A&)%->2$XSDJ3sn1^E1BPYKhMnRd166}Wrw1J2#|slzoOhcTthXzPW#K|`Bl!% z(9M3&R*l=u?#$~_Soq{qQ|fr%Gh?OTbp?0U`*%a*BrTKTW`3OW&$PjX;>Kd}sjm%+ z-FOxM-XveZA@cP3xG*EHIz{rL?Pq_xZA8Z}gM7sur5P-Y7=s-w>K81GpT&PQu`zCs zOP)fgiUCg{x=OfKvn3IvS|{7bKDo_Qmibp`>L=URGF+hI^bcKCTqzHp(>67@-8oKn z`p$*m51LcO_U?l*lJujKrd3~_SjKFDg{?9*kfk!`P)WhYyuew|%K%wT!5>e#g~~sVZLmFlNl%5t3BAJreuCR&Vi7qljH2+$fsJ^Jm#Kzhdb(0@m0e zocWm~Tu6&XpvvEGi$-b7ctge^ozL2%PkgsO_A+K+;_z$KJN<+=r5Yru$adAQep?pK zGy&4lOgYH@eoNjZcF7tV+mw6Eoa0J2^Jg{U?T^bOb&vQSvM+rTlO#lBCGN36((RA7 zf_OTh9S@}a&IBGO6;Tg4;4Z2@0l3MC$ID)@SBYKu%Vr)?&EE_#XjQ)g?tu1@&3YjT z#RvVx*bl1p_pey@9<4EFI2uS}&r+&Zz-8m~)I4%2 z!&gl)c0@~Y;dS;DZNh5D?+E3q4r?IQ`GtAo==HOJM)K*`fe6Z~4Y{N%z6_x*CHAZb zwZA)3qJTI4j9&!{J_Q+xE`XQ}Dcl@dByae;q=zs)>KRA?)(3LEP;cZp57+Vt}V;fhSEFKuuSxHfFY%LoF6u zhf4-q8WKOynf#=_!(~jvIUfPxvi1+}6XBm?4)ItOAHcjC96fW;U%w7eBla_2!lKb% zu}jgdIdp7d*4th*&IuEkjCZ`Dy9&Jhwrj`Oz!GNgc5pxPX}w~D>+^X#>zis_I|(tB z{G5)fY;$+BYT(E3Civf zRX7+Po%|Izfw{sd@9+9UDLtb;KF=)CPZ4;z=Q>14cKHCt*naE;$17NO?*K+0?-Ydc zwBgy11oo$rWH=qAG^%)?A(R7~8ntR9;FZ&-HZLCfC;qpm1Hej5r=yWca8m=j$g3D1 zHnINFH>$XkAQ0{RN-)iVj-X{m(Eer7!?ewaNtLa@4Q0A3^{TAYkqpGMH+-SzEh)|s z!z&<-&v|025jIfs#I75qU(q*%9pbDE2f;{(4=#79$NTgTk<2&KoBzo?a9$~X$!Xgh zs)&{zUu&+IHlU~Id}^k?pH<={Ky{brmZ?ii@%q*aHWh{BjDG0;wXPtB?8-hK%W z1t^+)cw{c;dN1hfJE*i2gPKjxatm=;R|s;0eV<=am4 zlq40%eCLPg9H}-AzsH!82jN8_2MT)FGtt4MuBveb-@=sw$E2~7Pr+YdUGQhn0%(wp zIkTdLC}CkKOBGDS>+`3|*zq-Yq=nj zi}$}f@qnK~oO3Lk@@Mm~gBG{3>`kTsQHRSLJ*o&cqWMQ7g z2$B(0d^PQG$-jZYPDHFSRfTh$s@XMk@!$!a-nZwSqsRk)53RAD2|!zou`NTwy~wL) zquOKcNXP$VjU1z!N1~cjnyOMv#~K@PI3~HM)ez=2YSxw#PrMbK-5?Fk-pd_vNH@-E9h+c{t zq9I;D5>v>efqL3(ry?~HXUQ^MGGqU++SZes)0uJk7IdAU@XBHVG5eUYCAVlD4}TrX z&OI2hr)}=&$uj7hkR14To~vUmEe1y9&xA+^_JYXII`-{{gH%tzhaOPl*H=C;jOiGM z3H*0RZm@l71u(EQ$Te>26ELsB=6B06|H4Z_fiZCZn~V5= zH_?{(FYFTZy9wmFe+3q>Z?*nMRPp~fwNUH7Fi)^=O@w>?75e|F^WTwK|GORbp?_hJ z;NP(S-U$8Qu$|3+VY2_g{#kne1q=k_1p)+w{693P*-P~W2j&G~IZW*a2PVe-uSI1y WARwgwfs{N+efvg0P=5YX{C@zmd2j{* diff --git a/Orange/distance/tests/test_distance.py b/Orange/distance/tests/test_distance.py index 37db5f04f02..c38ece49ed1 100644 --- a/Orange/distance/tests/test_distance.py +++ b/Orange/distance/tests/test_distance.py @@ -74,9 +74,12 @@ def is_same(d1, d2, fit1=None, fit2=None): is_same(data_nan, data_const, data_const) is_same(data_const, data_const, data_nan) - self.assertRaises(ValueError, self.Distance, data_const, axis=0) - self.assertRaises(ValueError, self.Distance, data_nan, axis=0) - self.assertRaises(ValueError, self.Distance, data_nan_1, axis=0) + self.assertRaises(ValueError, self.Distance, + data_const, axis=0, normalize=True) + self.assertRaises(ValueError, self.Distance, + data_nan, axis=0, normalize=True) + self.assertRaises(ValueError, self.Distance, + data_nan_1, axis=0, normalize=True) def test_mixed_cols(self): """distance over columns raises exception for discrete columns""" @@ -416,7 +419,7 @@ def test_manhattan_no_data(self): np.zeros((0, 3))) self.assertRaises( ValueError, - distance.Manhattan, Table(self.cont_domain), axis=0) + distance.Manhattan, Table(self.cont_domain), axis=0, normalize=True) def test_manhattan_disc(self): assert_almost_equal = np.testing.assert_almost_equal @@ -692,9 +695,9 @@ def test_cosine_disc(self): assert_almost_equal(params["means"], [2 / 3, 2 / 3, 1 / 3]) assert_almost_equal(params["vars"], [-1, -1, -1]) assert_almost_equal(params["dist_missing2"], [2 / 3, 2/ 3, 1 / 3]) - assert_almost_equal(dist, 1 - np.cos(np.array([[0, 0, 1 / sqrt(2)], - [0, 0, 0.5], - [1 / sqrt(2), 0.5, 0]]))) + assert_almost_equal(dist, 1 - np.array([[1, 0, 1 / sqrt(2)], + [0, 1, 0.5], + [1 / sqrt(2), 0.5, 1]])) data.X[1, 1] = np.nan model = distance.Cosine().fit(data) @@ -705,9 +708,9 @@ def test_cosine_disc(self): assert_almost_equal(params["dist_missing2"], [2 / 3, 1 / 2, 1 / 3]) assert_almost_equal( dist, - 1 - np.cos(np.array([[0, 0, 1 / sqrt(2)], - [0, 0, 0.5 / sqrt(1.5) / sqrt(2)], - [1 / sqrt(2), 0.5 / sqrt(1.5) / sqrt(2), 0]]))) + 1 - np.array([[1, 0, 1 / sqrt(2)], + [0, 1, 0.5 / sqrt(1.5) / sqrt(2)], + [1 / sqrt(2), 0.5 / sqrt(1.5) / sqrt(2), 1]])) data.X = np.array([[1, 0, 0], [0, np.nan, 1], @@ -717,10 +720,10 @@ def test_cosine_disc(self): dist = model(data) params = model.fit_params assert_almost_equal(params["means"], [0.75, 0.5, 0.75]) - assert_almost_equal(dist, [[0, 0, 0.1934216, 0.1620882], - [0, 0, 0.2852968, 0.2397554], - [0.1934216, 0.2852968, 0, 0.3885234], - [0.1620882, 0.2397554, 0.3885234, 0]]) + assert_almost_equal(dist, [[0, 1, 0.367544468, 0.422649731], + [1, 0, 0.225403331, 0.292893219], + [0.367544468, 0.225403331, 0, 0.087129071], + [0.422649731, 0.292893219, 0.087129071, 0]]) def test_cosine_cont(self): assert_almost_equal = np.testing.assert_almost_equal @@ -729,29 +732,29 @@ def test_cosine_cont(self): dist = distance.Cosine(data, axis=1) assert_almost_equal( dist, - [[0, 0.257364665, 0.398820559, 0.200841332], - [0.257364665, 0, 0.100822814, 0.002790265], - [0.398820559, 0.100822814, 0, 0.362758445], - [0.200841332, 0.002790265, 0.362758445, 0]] + [[0, 0.266200614, 0.0741799, 0.355097978], + [0.266200614, 0, 0.547089186, 0.925279678], + [0.0741799, 0.547089186, 0, 0.12011731], + [0.355097978, 0.925279678, 0.12011731, 0]] ) data.X[1, 0] = np.nan dist = distance.Cosine(data, axis=1) assert_almost_equal( dist, - [[0, 0.2630893, 0.3988206, 0.2008413], - [0.2630893, 0, 0.2433986, 0.1789183], - [0.3988206, 0.2433986, 0, 0.3627584], - [0.2008413, 0.1789183, 0.3627584, 0]]) + [[0, 0.257692511, 0.0741799, 0.35509797], + [0.257692511, 0, 0.287303355, 0.392507104], + [0.0741799, 0.287303355, 0, 0.12011731], + [0.355097978, 0.392507104, 0.12011731, 0]]) data.X[0, 0] = np.nan dist = distance.Cosine(data, axis=1) assert_almost_equal( dist, - [[0, 0.2424135, 0.3347198, 0.3207717], - [0.2424135, 0, 0.2580666, 0.2240018], - [0.3347198, 0.2580666, 0, 0.3627584], - [0.3207717, 0.2240018, 0.3627584, 0]]) + [[0, 0.288811225, 0.15707277, 0.175914357], + [0.288811225, 0, 0.265153077, 0.317499852], + [0.15707277, 0.265153077, 0, 0.12011731], + [0.175914357, 0.317499852, 0.12011731, 0]]) def test_cosine_mixed(self): assert_almost_equal = np.testing.assert_almost_equal @@ -769,9 +772,9 @@ def test_cosine_mixed(self): dist = model(data) assert_almost_equal( dist, - [[0, 0.2243992, 0.3092643], - [0.2243992, 0, 0.0879649], - [0.3092643, 0.0879649, 0]]) + [[0, 0.316869949, 0.191709623], + [0.316869949, 0, 0.577422873], + [0.191709623, 0.577422873, 0]]) def test_two_tables(self): assert_almost_equal = np.testing.assert_almost_equal @@ -781,22 +784,22 @@ def test_two_tables(self): dist = distance.Cosine(self.cont_data, self.cont_data2) assert_almost_equal( dist, - [[0.2931168, 0.231869], - [0.1011388, 0.1670357], - [0.3988206, 0.3092643], - [0.3389322, 0.2943107]]) + [[0.2142857, 0.3051208], + [0.5463676, 0.4136473], + [0.0741799, 0.1917096], + [0.1514447, 0.2125992]]) model = distance.Cosine().fit(self.cont_data) dist = model(self.cont_data, self.cont_data2) assert_almost_equal( dist, - [[0.2931168, 0.231869], - [0.1011388, 0.1670357], - [0.3988206, 0.3092643], - [0.3389322, 0.2943107]]) + [[0.2142857, 0.3051208], + [0.5463676, 0.4136473], + [0.0741799, 0.1917096], + [0.1514447, 0.2125992]]) dist = model(self.cont_data2) - assert_almost_equal(dist, [[0, 0.26717482], [0.26717482, 0]]) + assert_almost_equal(dist, [[0, 0.251668523], [0.251668523, 0]]) def test_cosine_cols(self): @@ -806,26 +809,26 @@ def test_cosine_cols(self): dist = distance.Cosine(data, axis=0, normalize=False) assert_almost_equal( dist, - [[0, 0.0413781, 0.3701989], - [0.0413781, 0, 0.150811], - [0.3701989, 0.150811, 0]]) + [[0, 0.711324865, 0.11050082], + [0.711324865, 0, 0.44365136], + [0.11050082, 0.44365136, 0]]) data.X[1, 1] = np.nan dist = distance.Cosine(data, axis=0, normalize=False) assert_almost_equal( dist, - [[0, 0.1289953, 0.3701989], - [0.1289953, 0, 0.3062882], - [0.3701989, 0.3062882, 0]]) + [[0, 0.486447409, 0.11050082], + [0.486447409, 0, 0.195833554], + [0.11050082, 0.195833554, 0]]) data.X[1, 0] = np.nan data.X[1, 2] = 2 dist = distance.Cosine(data, axis=0, normalize=False) assert_almost_equal( dist, - [[0, 0.2184396, 0.3456646], - [0.2184396, 0, 0.4001047], - [0.3456646, 0.4001047, 0]]) + [[0, 0.32636693, 0.142507074], + [0.32636693, 0, 0.072573966], + [0.142507074, 0.072573966, 0]]) class JaccardDistanceTest(unittest.TestCase, CommonFittedTests): @@ -847,10 +850,10 @@ def test_jaccard_rows(self): assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), - 1 - np.array([[0, 2/3, 1/3, 0], - [2/3, 0, 2/3, 1/3], - [1/3, 2/3, 0, 1/2], - [0, 1/3, 1/2, 0]])) + 1 - np.array([[1, 2/3, 1/3, 0], + [2/3, 1, 2/3, 1/3], + [1/3, 2/3, 1, 1/2], + [0, 1/3, 1/2, 1]])) X = self.data.X X[1, 0] = X[2, 0] = X[3, 1] = np.nan @@ -858,10 +861,10 @@ def test_jaccard_rows(self): assert_almost_equal(model.fit_params["ps"], np.array([0.5, 2/3, 0.75])) assert_almost_equal( model(self.data), - 1 - np.array([[ 0, 2 / 2.5, 1 / 2.5, 2/3 / 3], - [2 / 2.5, 0, 1.25 / 2.75, (1/2+2/3) / 3], - [1 / 2.5, 1.25 / 2.75, 0, 0.5 / (2+2/3)], - [2/3 / 3, (1/2+2/3) / 3, 0.5 / (2+2/3), 0]])) + 1 - np.array([[ 1, 2 / 2.5, 1 / 2.5, 2/3 / 3], + [2 / 2.5, 1, 1.25 / 2.75, (1/2+2/3) / 3], + [1 / 2.5, 1.25 / 2.75, 1, 0.5 / (2+2/3)], + [2/3 / 3, (1/2+2/3) / 3, 0.5 / (2+2/3), 1]])) def test_jaccard_cols(self): assert_almost_equal = np.testing.assert_almost_equal @@ -869,9 +872,9 @@ def test_jaccard_cols(self): assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), - 1 - np.array([[0, 1/4, 1/2], - [1/4, 0, 2/3], - [1/2, 2/3, 0]])) + 1 - np.array([[1, 1/4, 1/2], + [1/4, 1, 2/3], + [1/2, 2/3, 1]])) self.data.X = np.array([[0, 1, 1], [np.nan, np.nan, 1], @@ -881,9 +884,9 @@ def test_jaccard_cols(self): assert_almost_equal(model.fit_params["ps"], [0.5, 2/3, 0.75]) assert_almost_equal( model(self.data), - 1 - np.array([[0, 0.4, 0.25], - [0.4, 0, 5/12], - [0.25, 5/12, 0]])) + 1 - np.array([[1, 0.4, 0.25], + [0.4, 1, 5/12], + [0.25, 5/12, 1]])) if __name__ == "__main__": From a45ad224119d6ec3475b1d620a3130ace993c700 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 15:30:31 +0200 Subject: [PATCH 05/27] distances: Remove inapplicable old tests --- Orange/tests/test_distances.py | 39 ---------------------------------- 1 file changed, 39 deletions(-) diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index 84e5ff25adb..a1124f5a29a 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -2,7 +2,6 @@ # pylint: disable=missing-docstring from unittest import TestCase -import os import pickle import numpy as np @@ -214,11 +213,6 @@ def test_euclidean_distance_many_examples(self): np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), np.array([[0., 0.53851648, 0.50990195], [0.53851648, 0., 0.3]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:2], axis=0), - np.array([[0., 2.48394847, 5.09313263, 6.78969808], - [2.48394847, 0., 2.64007576, 4.327817], - [5.09313263, 2.64007576, 0., 1.69705627], - [6.78969808, 4.327817, 1.69705627, 0.]])) def test_euclidean_distance_sparse(self): np.testing.assert_almost_equal(self.dist(self.sparse), @@ -281,11 +275,6 @@ def test_manhattan_distance_many_examples(self): np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), np.array([[0., 0.7, 0.8], [0.7, 0., 0.5]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:2], axis=0), - np.array([[0., 3.5, 7.2, 9.6], - [3.5, 0., 3.7, 6.1], - [7.2, 3.7, 0., 2.4], - [9.6, 6.1, 2.4, 0.]])) def test_manhattan_distance_sparse(self): np.testing.assert_almost_equal(self.dist(self.sparse), @@ -347,11 +336,6 @@ def test_cosine_distance_many_examples(self): np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), np.array([[0.0, 1.42083650e-03, 1.26527175e-05], [1.42083650e-03, 0.0, 1.20854727e-03]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:2], axis=0), - np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04], - [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03], - [1.99940020e-04, 2.94551450e-03, 0.0, 0.0], - [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]])) def test_cosine_distance_sparse(self): np.testing.assert_almost_equal(self.dist(self.sparse), @@ -413,10 +397,6 @@ def test_jaccard_distance_many_examples(self): np.testing.assert_almost_equal(self.dist(self.titanic[:2], self.titanic[:3]), np.array([[0., 0., 0.5], [0., 0., 0.5]])) - np.testing.assert_almost_equal(self.dist(self.titanic, self.titanic, axis=0), - np.array([[0., 1., 0.5], - [1., np.nan, 1.], - [0.5, 1., 0.]])) def test_jaccard_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.titanic[0].x, self.titanic[2].x, axis=1), np.array([[0.5]])) @@ -771,14 +751,6 @@ def test_iris(self): self.assertEqual(metric(tab).shape, (150, 150)) self.assertEqual(metric(tab[0], tab[1]).shape, (1, 1)) - def test_axis(self): - mah = MahalanobisDistance(self.x, axis=1) - self.assertEqual(mah(self.x, self.x).shape, (self.n, self.n)) - x = self.x.T - mah = MahalanobisDistance(x, axis=0) - self.assertRaises(AssertionError, mah, x, axis=1) - self.assertEqual(mah(x, x).shape, (self.n, self.n)) - def test_dimensions(self): x = Table('iris')[:20].X xt = Table('iris')[:20].X.T @@ -787,17 +759,6 @@ def test_dimensions(self): mah = MahalanobisDistance(xt) mah(xt[0], xt[1]) - def test_global_is_borked(self): - """ - Test that the global state retaining non-safe Mahalanobis instance - raises RuntimeErrors on all invocations - """ - from Orange.distance import Mahalanobis - with self.assertRaises(RuntimeError): - Mahalanobis.fit(self.x) - with self.assertRaises(RuntimeError): - Mahalanobis(self.x) - class TestDistances(TestCase): @classmethod From ef9df3a489c0e13c2d96cdc623e7d54cf45cc6ed Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 16:21:38 +0200 Subject: [PATCH 06/27] distances: Improve fallbacks to skl distances --- Orange/distance/__init__.py | 155 ++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 70 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index f59eba11ce2..20c8476479b 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -14,7 +14,10 @@ 'MahalanobisDistance'] -def _preprocess(table): +# TODO this *private* function is called from several widgets to prepare +# data for calling the below classes. After we (mostly) stopped relying +# on sklearn.metrics, this is (mostly) unnecessary +def _preprocess(table, impute=True): """Remove categorical attributes and impute missing values.""" if not len(table): return table @@ -23,7 +26,8 @@ def _preprocess(table): table.domain.class_vars, table.domain.metas) new_data = table.transform(new_domain) - new_data = SklImpute()(new_data) + if impute: + new_data = SklImpute()(new_data) return new_data @@ -42,6 +46,10 @@ def _orange_to_numpy(x): class Distance: + supports_sparse = False + supports_discrete = False + supports_normalization = False + def __new__(cls, e1=None, e2=None, axis=1, **kwargs): self = super().__new__(cls) self.axis = axis @@ -53,12 +61,11 @@ def __new__(cls, e1=None, e2=None, axis=1, **kwargs): # Handling sparse data and maintaining backwards compatibility with # old-style calls - if not hasattr(e1, "domain") \ - or hasattr(e1, "is_sparse") and e1.is_sparse(): - fallback = fallbacks.get(self.__class__.__name__, None) - if fallback: - return fallback(e1, e2, axis, - impute=kwargs.get("impute", False)) + if (not hasattr(e1, "domain") + or hasattr(e1, "is_sparse") and e1.is_sparse()) \ + and self.fallback: + return self.fallback(e1, e2, axis, + impute=kwargs.get("impute", False)) model = self.fit(e1) return model(e1, e2) @@ -86,7 +93,11 @@ def __call__(self, e1, e2=None): A distance matrix (Orange.misc.distmatrix.DistMatrix) """ if self.axis == 0 and e2 is not None: - raise ValueError("Two tables cannot be compared by columns") + # Backward compatibility fix + if e2 is e1: + e2 = None + else: + raise ValueError("Two tables cannot be compared by columns") x1 = _orange_to_numpy(e1) x2 = _orange_to_numpy(e2) @@ -146,13 +157,67 @@ def fit_rows(self, x, n_vals): pass +# Fallbacks for distances in sparse data +# To be removed as the corresponding functionality is implemented above + +class SklDistance: + def __init__(self, metric, name, supports_sparse): + """ + Args: + metric: The metric to be used for distance calculation + name (str): Name of the distance + supports_sparse (boolean): Whether this metric works on sparse data + or not. + """ + self.metric = metric + self.name = name + self.supports_sparse = supports_sparse + + def __call__(self, e1, e2=None, axis=1, impute=False): + """ + :param e1: input data instances, we calculate distances between all + pairs + :type e1: :class:`Orange.data.Table` or + :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` + :param e2: optional second argument for data instances if provided, + distances between each pair, where first item is from e1 and + second is from e2, are calculated + :type e2: :class:`Orange.data.Table` or + :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` + :param axis: if axis=1 we calculate distances between rows, if axis=0 + we calculate distances between columns + :type axis: int + :param impute: if impute=True all NaN values in matrix are replaced + with 0 + :type impute: bool + :return: the matrix with distances between given examples + :rtype: :class:`Orange.misc.distmatrix.DistMatrix` + """ + x1 = _orange_to_numpy(e1) + x2 = _orange_to_numpy(e2) + if axis == 0: + x1 = x1.T + if x2 is not None: + x2 = x2.T + dist = skl_metrics.pairwise.pairwise_distances( + x1, x2, metric=self.metric) + if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): + dist = DistMatrix(dist, e1, e2, axis) + else: + dist = DistMatrix(dist) + return dist + + class EuclideanModel(FittedDistanceModel): - supports_sparse = True # via fallback distance_by_cols = _distance.euclidean_cols distance_by_rows = _distance.euclidean_rows class Euclidean(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + supports_normalization = True + fallback = SklDistance('euclidean', 'Euclidean', True) ModelType = EuclideanModel def __new__(cls, *args, **kwargs): @@ -204,12 +269,15 @@ def fit_cols(self, x, n_vals): class ManhattanModel(FittedDistanceModel): - supports_sparse = True # via fallback distance_by_cols = _distance.manhattan_cols distance_by_rows = _distance.manhattan_rows class Manhattan(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + supports_normalization = True + fallback = SklDistance('manhattan', 'Manhattan', True) ModelType = ManhattanModel def __new__(cls, *args, **kwargs): @@ -260,12 +328,14 @@ def fit_cols(self, x, n_vals): class CosineModel(FittedDistanceModel): - supports_sparse = True # via fallback distance_by_rows = _distance.cosine_rows distance_by_cols = _distance.cosine_cols class Cosine(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + fallback = SklDistance('cosine', 'Cosine', True) ModelType = CosineModel def __new__(cls, *args, **kwargs): @@ -301,12 +371,14 @@ def fit_rows(self, x, n_vals): class JaccardModel(FittedDistanceModel): - supports_sparse = False distance_by_cols = _distance.jaccard_cols distance_by_rows = _distance.jaccard_rows class Jaccard(FittedDistance): + supports_sparse = False + supports_discrete = True + fallback = SklDistance('jaccard', 'Jaccard', True) ModelType = JaccardModel def fit_rows(self, x, n_vals): @@ -457,60 +529,3 @@ def __new__(self, data=None, axis=1, _='Mahalanobis'): if data is None: return MahalanobisDistance return Mahalanobis().fit(data, axis) - - -# Fallbacks for distances in sparse data -# To be removed as the corresponding functionality is implemented above - - -class SklDistance: - def __init__(self, metric, name, supports_sparse): - """ - Args: - metric: The metric to be used for distance calculation - name (str): Name of the distance - supports_sparse (boolean): Whether this metric works on sparse data - or not. - """ - self.metric = metric - self.name = name - self.supports_sparse = supports_sparse - - def __call__(self, e1, e2=None, axis=1, impute=False): - """ - :param e1: input data instances, we calculate distances between all - pairs - :type e1: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param e2: optional second argument for data instances if provided, - distances between each pair, where first item is from e1 and - second is from e2, are calculated - :type e2: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param axis: if axis=1 we calculate distances between rows, if axis=0 - we calculate distances between columns - :type axis: int - :param impute: if impute=True all NaN values in matrix are replaced - with 0 - :type impute: bool - :return: the matrix with distances between given examples - :rtype: :class:`Orange.misc.distmatrix.DistMatrix` - """ - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) - if axis == 0: - x1 = x1.T - if x2 is not None: - x2 = x2.T - dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric=self.metric) - if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, axis) - else: - dist = DistMatrix(dist) - return dist - -fallbacks = dict(Euclidean=SklDistance('euclidean', 'Euclidean', True), - Manhattan=SklDistance('manhattan', 'Manhattan', True), - Cosine=SklDistance('cosine', 'Cosine', True), - Jaccard=SklDistance('jaccard', 'Jaccard', False)) From cada2eecf6b1f676a5593c30a575c00001373706 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 16:22:03 +0200 Subject: [PATCH 07/27] distances: Adapt OWDistances to new distance classes --- Orange/widgets/unsupervised/owdistances.py | 84 ++++++++-------------- 1 file changed, 30 insertions(+), 54 deletions(-) diff --git a/Orange/widgets/unsupervised/owdistances.py b/Orange/widgets/unsupervised/owdistances.py index 62b15f2d9fb..90e00aeee60 100644 --- a/Orange/widgets/unsupervised/owdistances.py +++ b/Orange/widgets/unsupervised/owdistances.py @@ -1,4 +1,3 @@ -import bottleneck as bn from AnyQt.QtCore import Qt from scipy.sparse import issparse @@ -9,21 +8,17 @@ from Orange.widgets.utils.sql import check_sql_input from Orange.widgets.widget import OWWidget, Msg, Input, Output -# A placeholder. This metric is handled specially in commit method. -__Mahalanobis = distance.MahalanobisDistance() -__Mahalanobis.fit = None - METRICS = [ - distance.Euclidean, - distance.Manhattan, - __Mahalanobis, - distance.Cosine, - distance.Jaccard, - distance.SpearmanR, - distance.SpearmanRAbsolute, - distance.PearsonR, - distance.PearsonRAbsolute, + ("Euclidean", distance.Euclidean), + ("Manhattan", distance.Manhattan), + ("Mahalanobis", distance.Mahalanobis), + ("Cosine", distance.Cosine), + ("Jaccard", distance.Jaccard), + ("Spearman", distance.SpearmanR), + ("Absolute Spearman", distance.SpearmanRAbsolute), + ("Pearson", distance.PearsonR), + ("Absolute Pearson", distance.PearsonRAbsolute), ] @@ -67,7 +62,7 @@ def __init__(self): ) self.metrics_combo = gui.comboBox(self.controlArea, self, "metric_idx", box="Distance Metric", - items=[m.name for m in METRICS], + items=[m[0] for m in METRICS], callback=self._invalidate ) box = gui.auto_commit(self.buttonsArea, self, "autocommit", "Apply", @@ -94,7 +89,7 @@ def refresh_metrics(self): sparse = self.data is not None and issparse(self.data.X) for i, metric in enumerate(METRICS): item = self.metrics_combo.model().item(i) - item.setEnabled(not sparse or metric.supports_sparse) + item.setEnabled(not sparse or metric[1].supports_sparse) self._checksparse() @@ -103,59 +98,40 @@ def _checksparse(self): # appropriate informational GUI state self.Error.dense_metric_sparse_data( shown=self.data is not None and issparse(self.data.X) and - not METRICS[self.metric_idx].supports_sparse) + not METRICS[self.metric_idx][1].supports_sparse) def commit(self): - metric = METRICS[self.metric_idx] - self.Outputs.distances.send(self.compute_distances(metric, self.data)) + metric = METRICS[self.metric_idx][1] + dist = self.compute_distances(metric, self.data) + self.Outputs.distances.send(dist) def compute_distances(self, metric, data): def checks(metric, data): if data is None: return - - if issparse(data.X) and not metric.supports_sparse: - self.Error.dense_metric_sparse_data() - return - - if not any(a.is_continuous for a in data.domain.attributes): - self.Error.no_continuous_features() - return - - needs_preprocessing = False - if any(a.is_discrete for a in self.data.domain.attributes): - self.Warning.ignoring_discrete() - needs_preprocessing = True - - if not issparse(data.X) and bn.anynan(data.X): - self.Warning.imputing_data() - needs_preprocessing = True - - if needs_preprocessing: - # removes discrete features and imputes data - data = distance._preprocess(data) - + if issparse(data.X): + if not metric.supports_sparse: + self.Error.dense_metric_sparse_data() + return + remove_discrete = metric.fallback is not None \ + and self.data.domain.has_discrete_attributes() + else: # not sparse + remove_discrete = \ + not metric.supports_discrete or self.axis == 1 \ + and self.data.domain.has_discrete_attributes() + if remove_discrete: + data = distance._preprocess(data, impute=False) + if data.X.size: + self.Warning.ignoring_discrete() if not data.X.size: self.Error.empty_data() return - return data self.clear_messages() - data = checks(metric, data) if data is None: return - - if isinstance(metric, distance.MahalanobisDistance): - # Mahalanobis distance has to be trained before it can be used - # to compute distances - try: - metric = distance.MahalanobisDistance(data, axis=1 - self.axis) - except (ValueError, MemoryError) as e: - self.Error.mahalanobis_error(e) - return - try: met = metric(data, data, 1 - self.axis, impute=True) except ValueError as e: @@ -173,5 +149,5 @@ def _invalidate(self): def send_report(self): self.report_items(( ("Distances Between", ["Rows", "Columns"][self.axis]), - ("Metric", METRICS[self.metric_idx].name) + ("Metric", METRICS[self.metric_idx][0]) )) From adbb9883f34d9998859631864e7ee2bf34ad2fd8 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 22:56:50 +0200 Subject: [PATCH 08/27] distances: Refactoring of Pearson and Spearman --- Orange/distance/__init__.py | 166 ++++++++++++++++----------------- Orange/tests/test_distances.py | 80 ---------------- 2 files changed, 78 insertions(+), 168 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 20c8476479b..78167c59490 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -3,13 +3,13 @@ import sklearn.metrics as skl_metrics -from Orange import data +from Orange.data import Table, Domain, Instance, RowInstance from Orange.misc import DistMatrix from Orange.distance import _distance from Orange.statistics import util from Orange.preprocess import SklImpute -__all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', '`SpearmanR', +__all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', 'SpearmanR', 'SpearmanRAbsolute', 'PearsonR', 'PearsonRAbsolute', 'Mahalanobis', 'MahalanobisDistance'] @@ -21,7 +21,7 @@ def _preprocess(table, impute=True): """Remove categorical attributes and impute missing values.""" if not len(table): return table - new_domain = data.Domain( + new_domain = Domain( [a for a in table.domain.attributes if a.is_continuous], table.domain.class_vars, table.domain.metas) @@ -31,13 +31,25 @@ def _preprocess(table, impute=True): return new_data +def remove_discrete_features(data): + new_domain = Domain( + [a for a in data.domain.attributes if a.is_continuous], + data.domain.class_vars, + data.domain.metas) + return data.transform(new_domain) + + +def impute(data): + return SklImpute()(data) + + def _orange_to_numpy(x): """Convert :class:`Orange.data.Table` and :class:`Orange.data.RowInstance` to :class:`numpy.ndarray`. """ - if isinstance(x, data.Table): + if isinstance(x, Table): return x.X - elif isinstance(x, data.Instance): + elif isinstance(x, Instance): return np.atleast_2d(x.x) elif isinstance(x, np.ndarray): return np.atleast_2d(x) @@ -49,6 +61,7 @@ class Distance: supports_sparse = False supports_discrete = False supports_normalization = False + supports_missing = True def __new__(cls, e1=None, e2=None, axis=1, **kwargs): self = super().__new__(cls) @@ -62,10 +75,11 @@ def __new__(cls, e1=None, e2=None, axis=1, **kwargs): # Handling sparse data and maintaining backwards compatibility with # old-style calls if (not hasattr(e1, "domain") - or hasattr(e1, "is_sparse") and e1.is_sparse()) \ - and self.fallback: - return self.fallback(e1, e2, axis, - impute=kwargs.get("impute", False)) + or hasattr(e1, "is_sparse") and e1.is_sparse()): + fallback = getattr(self, "fallback", None) + if fallback is not None: + return fallback(e1, e2, axis, + impute=kwargs.get("impute", False)) model = self.fit(e1) return model(e1, e2) @@ -102,7 +116,7 @@ def __call__(self, e1, e2=None): x1 = _orange_to_numpy(e1) x2 = _orange_to_numpy(e2) dist = self.compute_distances(x1, x2) - if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): + if isinstance(e1, Table) or isinstance(e1, RowInstance): dist = DistMatrix(dist, e1, e2, self.axis) else: dist = DistMatrix(dist) @@ -200,12 +214,12 @@ def __call__(self, e1, e2=None, axis=1, impute=False): if x2 is not None: x2 = x2.T dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric=self.metric) - if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, axis) + x1, x2, metric=self.metric) + if isinstance(e1, Table) or isinstance(e1, RowInstance): + dist_matrix = DistMatrix(dist, e1, e2, axis) else: - dist = DistMatrix(dist) - return dist + dist_matrix = DistMatrix(dist) + return dist_matrix class EuclideanModel(FittedDistanceModel): @@ -390,98 +404,74 @@ def fit_rows(self, x, n_vals): fit_cols = fit_rows -class SpearmanDistance(Distance): - supports_sparse = False - - """ Generic Spearman's rank correlation coefficient. """ - def __init__(self, absolute): - """ - Constructor for Spearman's and Absolute Spearman's distances. - - Args: - absolute (boolean): Whether to use absolute values or not. - - Returns: - If absolute=True return Spearman's Absolute rank class else return - Spearman's rank class. - """ +class CorrelationDistanceModel(DistanceModel): + def __init__(self, absolute, axis=1, impute=False): + super().__init__(axis, impute) self.absolute = absolute - def __call__(self, e1, e2=None, axis=1, impute=False): - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) + def compute_distances(self, x1, x2): if x2 is None: x2 = x1 - slc = len(x1) if axis == 1 else x1.shape[1] - rho, _ = stats.spearmanr(x1, x2, axis=axis) + rho = self.compute_correlation(x1, x2) if np.isnan(rho).any() and impute: rho = np.nan_to_num(rho) if self.absolute: - dist = (1. - np.abs(rho)) / 2. - else: - dist = (1. - rho) / 2. - if isinstance(dist, np.float): - dist = np.array([[dist]]) - elif isinstance(dist, np.ndarray): - dist = dist[:slc, slc:] - if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, axis) + return (1. - np.abs(rho)) / 2. else: - dist = DistMatrix(dist) - return dist + return (1. - rho) / 2. -SpearmanR = SpearmanDistance(absolute=False) -SpearmanRAbsolute = SpearmanDistance(absolute=True) + def compute_correlation(self, x1, x2): + pass -class PearsonDistance(Distance): - supports_sparse = False +class SpearmanModel(CorrelationDistanceModel): + def compute_correlation(self, x1, x2): + rho = stats.spearmanr(x1, x2, axis=self.axis)[0] + if isinstance(rho, np.float): + return np.array([[rho]]) + slc = x1.shape[1 - self.axis] + return rho[:slc, slc:] - """ Generic Pearson's rank correlation coefficient. """ - def __init__(self, absolute): - """ - Constructor for Pearson's and Absolute Pearson's distances. - Args: - absolute (boolean): Whether to use absolute values or not. +class CorrelationDistance(Distance): + supports_missing = False - Returns: - If absolute=True return Pearson's Absolute rank class else return - Pearson's rank class. - """ - self.absolute = absolute - def __call__(self, e1, e2=None, axis=1, impute=False): - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) - if x2 is None: - x2 = x1 - if axis == 0: +class SpearmanR(CorrelationDistance): + def fit(self, _): + return SpearmanModel(False, self.axis, getattr(self, "impute", False)) + + +class SpearmanRAbsolute(CorrelationDistance): + def fit(self, _): + return SpearmanModel(True, self.axis, getattr(self, "impute", False)) + + +class PearsonModel(CorrelationDistanceModel): + def compute_correlation(self, x1, x2): + if self.axis == 0: x1 = x1.T x2 = x2.T - rho = np.array([[stats.pearsonr(i, j)[0] for j in x2] for i in x1]) - if np.isnan(rho).any() and impute: - rho = np.nan_to_num(rho) - if self.absolute: - dist = (1. - np.abs(rho)) / 2. - else: - dist = (1. - rho) / 2. - if isinstance(e1, data.Table) or isinstance(e1, data.RowInstance): - dist = DistMatrix(dist, e1, e2, axis) - else: - dist = DistMatrix(dist) - return dist + return np.array([[stats.pearsonr(i, j)[0] for j in x2] for i in x1]) -PearsonR = PearsonDistance(absolute=False) -PearsonRAbsolute = PearsonDistance(absolute=True) + +class PearsonR(CorrelationDistance): + def fit(self, _): + return PearsonModel(False, self.axis, getattr(self, "impute", False)) + + +class PearsonRAbsolute(CorrelationDistance): + def fit(self, _): + return PearsonModel(True, self.axis, getattr(self, "impute", False)) class Mahalanobis(Distance): supports_sparse = False + supports_missing = False - def fit(self, data, axis=1): + def fit(self, data): x = _orange_to_numpy(data) - if axis == 0: + if self.axis == 0: x = x.T try: c = np.cov(x.T) @@ -491,7 +481,7 @@ def fit(self, data, axis=1): vi = np.linalg.inv(c) except: raise ValueError("Computation of inverse covariance matrix failed.") - return MahalanobisModel(axis, getattr(self, "impute", False), vi) + return MahalanobisModel(self.axis, getattr(self, "impute", False), vi) class MahalanobisModel(DistanceModel): @@ -516,7 +506,7 @@ def compute_distances(self, x1, x2): raise ValueError('Incorrect number of features.') dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric='mahalanobis', VI=self.vi) + x1, x2, metric='mahalanobis', VI=self.vi) if np.isnan(dist).any() and self.impute: dist = np.nan_to_num(dist) return dist @@ -525,7 +515,7 @@ def compute_distances(self, x1, x2): # Backward compatibility class MahalanobisDistance: - def __new__(self, data=None, axis=1, _='Mahalanobis'): + def __new__(cls, data=None, axis=1, _='Mahalanobis'): if data is None: - return MahalanobisDistance - return Mahalanobis().fit(data, axis) + return cls + return Mahalanobis(axis=axis).fit(data) diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index a1124f5a29a..019f831abbb 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -459,16 +459,6 @@ def test_spearmanr_distance_many_examples(self): np. array([[0.075], [0.3833333], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:3], axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]])) def test_spearmanr_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), @@ -482,16 +472,6 @@ def test_spearmanr_distance_numpy(self): np. array([[0.075], [0.3833333], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3].X, self.breast[:3].X, axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]])) class TestSpearmanRAbsolute(TestCase): @@ -535,16 +515,6 @@ def test_spearmanrabsolute_distance_many_examples(self): [0.4666667], [0.3666667], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:3], axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]])) def test_spearmanrabsolute_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), @@ -559,16 +529,6 @@ def test_spearmanrabsolute_distance_numpy(self): [0.4666667], [0.3666667], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3].X, self.breast[:3].X, axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]])) class TestPearsonR(TestCase): @@ -610,16 +570,6 @@ def test_pearsonr_distance_many_examples(self): np.array([[0.10133593], [0.32783865], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20], self.breast[:20], axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]])) def test_pearsonr_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), @@ -633,16 +583,6 @@ def test_pearsonr_distance_numpy(self): np.array([[0.10133593], [0.32783865], [0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20].X, self.breast[:20].X, axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]])) class TestPearsonRAbsolute(TestCase): @@ -683,16 +623,6 @@ def test_pearsonrabsolute_distance_many_examples(self): np.testing.assert_almost_equal(self.dist(self.breast[:2], self.breast[3]), np.array([[0.4983256], [0.42682613]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20], self.breast[:20], axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]])) def test_pearsonrabsolute_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), @@ -705,16 +635,6 @@ def test_pearsonrabsolute_distance_numpy(self): np.testing.assert_almost_equal(self.dist(self.breast[:2].X, self.breast[3].x), np.array([[0.4983256], [0.42682613]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20].X, self.breast[:20].X, axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]])) class TestMahalanobis(TestCase): From 4534c144b0ff5946d69141a0c46b378120c512e6 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 22:57:37 +0200 Subject: [PATCH 09/27] distances: Clip cosine distances to (0, 1) --- Orange/distance/_distance.c | 690 ++++++++++++++++++++-------------- Orange/distance/_distance.pyx | 16 +- 2 files changed, 420 insertions(+), 286 deletions(-) diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index 4d42094089c..8c9d4489fe2 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -6812,8 +6812,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * d += val1 * means[col] * else: * d += val1 * val2 # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] - * if not two_tables: + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors */ /*else*/ { __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); @@ -6827,15 +6827,82 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS /* "Orange/distance/_distance.pyx":333 * else: * d += val1 * val2 - * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) + * d = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< + * if d < 0: # clip off any numeric errors + * d = 0 */ __pyx_t_33 = __pyx_v_row1; __pyx_t_34 = __pyx_v_row2; + __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":334 + * d += val1 * val2 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: + */ + __pyx_t_5 = ((__pyx_v_d < 0.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":335 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors + * d = 0 # <<<<<<<<<<<<<< + * elif d > 1: + * d = 1 + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":334 + * d += val1 * val2 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: + */ + goto __pyx_L24; + } + + /* "Orange/distance/_distance.pyx":336 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[row1, row2] = d + */ + __pyx_t_5 = ((__pyx_v_d > 1.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":337 + * d = 0 + * elif d > 1: + * d = 1 # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * if not two_tables: + */ + __pyx_v_d = 1.0; + + /* "Orange/distance/_distance.pyx":336 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[row1, row2] = d + */ + } + __pyx_L24:; + + /* "Orange/distance/_distance.pyx":338 + * elif d > 1: + * d = 1 + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if not two_tables: + * _lower_to_symmetric(distances) + */ __pyx_t_35 = __pyx_v_row1; __pyx_t_36 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } } } @@ -6858,9 +6925,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":334 - * d += val1 * val2 - * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] + /* "Orange/distance/_distance.pyx":339 + * d = 1 + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances @@ -6868,8 +6935,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":335 - * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] + /* "Orange/distance/_distance.pyx":340 + * distances[row1, row2] = d * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances @@ -6877,16 +6944,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":334 - * d += val1 * val2 - * distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] + /* "Orange/distance/_distance.pyx":339 + * d = 1 + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":336 + /* "Orange/distance/_distance.pyx":341 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -6894,7 +6961,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6942,7 +7009,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":339 +/* "Orange/distance/_distance.pyx":344 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -6983,7 +7050,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli Py_ssize_t __pyx_t_20; __Pyx_RefNannySetupContext("_abs_cols", 0); - /* "Orange/distance/_distance.pyx":345 + /* "Orange/distance/_distance.pyx":350 * int row, col, n_rows, n_cols, nan_cont * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -6995,19 +7062,19 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":346 + /* "Orange/distance/_distance.pyx":351 * * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) # <<<<<<<<<<<<<< * with nogil: * for col in range(n_cols): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { @@ -7020,29 +7087,29 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 346, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":347 + /* "Orange/distance/_distance.pyx":352 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7056,7 +7123,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":348 + /* "Orange/distance/_distance.pyx":353 * abss = np.empty(n_cols) * with nogil: * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -7067,7 +7134,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col = __pyx_t_10; - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":354 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -7078,7 +7145,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":350 + /* "Orange/distance/_distance.pyx":355 * for col in range(n_cols): * if vars[col] == -2: * abss[col] = 1 # <<<<<<<<<<<<<< @@ -7088,7 +7155,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_13 = __pyx_v_col; *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; - /* "Orange/distance/_distance.pyx":351 + /* "Orange/distance/_distance.pyx":356 * if vars[col] == -2: * abss[col] = 1 * continue # <<<<<<<<<<<<<< @@ -7097,7 +7164,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ goto __pyx_L6_continue; - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":354 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -7106,7 +7173,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ } - /* "Orange/distance/_distance.pyx":352 + /* "Orange/distance/_distance.pyx":357 * abss[col] = 1 * continue * d = 0 # <<<<<<<<<<<<<< @@ -7115,7 +7182,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":353 + /* "Orange/distance/_distance.pyx":358 * continue * d = 0 * nan_cont = 0 # <<<<<<<<<<<<<< @@ -7124,7 +7191,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_nan_cont = 0; - /* "Orange/distance/_distance.pyx":354 + /* "Orange/distance/_distance.pyx":359 * d = 0 * nan_cont = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7135,7 +7202,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":355 + /* "Orange/distance/_distance.pyx":360 * nan_cont = 0 * for row in range(n_rows): * val = x[row, col] # <<<<<<<<<<<<<< @@ -7146,7 +7213,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_17 = __pyx_v_col; __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":356 + /* "Orange/distance/_distance.pyx":361 * for row in range(n_rows): * val = x[row, col] * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -7156,7 +7223,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":357 + /* "Orange/distance/_distance.pyx":362 * val = x[row, col] * if npy_isnan(val): * nan_cont += 1 # <<<<<<<<<<<<<< @@ -7165,7 +7232,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); - /* "Orange/distance/_distance.pyx":356 + /* "Orange/distance/_distance.pyx":361 * for row in range(n_rows): * val = x[row, col] * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -7175,7 +7242,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":359 + /* "Orange/distance/_distance.pyx":364 * nan_cont += 1 * else: * d += val ** 2 # <<<<<<<<<<<<<< @@ -7188,7 +7255,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_L11:; } - /* "Orange/distance/_distance.pyx":360 + /* "Orange/distance/_distance.pyx":365 * else: * d += val ** 2 * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< @@ -7199,7 +7266,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_19 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":361 + /* "Orange/distance/_distance.pyx":366 * d += val ** 2 * d += nan_cont * (means[col] ** 2 + vars[col]) * abss[col] = sqrt(d) # <<<<<<<<<<<<<< @@ -7212,7 +7279,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":347 + /* "Orange/distance/_distance.pyx":352 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7230,7 +7297,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":362 + /* "Orange/distance/_distance.pyx":367 * d += nan_cont * (means[col] ** 2 + vars[col]) * abss[col] = sqrt(d) * return abss # <<<<<<<<<<<<<< @@ -7238,13 +7305,13 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":344 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -7269,7 +7336,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli return __pyx_r; } -/* "Orange/distance/_distance.pyx":365 +/* "Orange/distance/_distance.pyx":370 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -7307,11 +7374,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *_ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 365, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 370, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 365, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 370, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -7324,13 +7391,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 365, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 370, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 365, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 370, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -7397,11 +7464,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS Py_ssize_t __pyx_t_34; Py_ssize_t __pyx_t_35; Py_ssize_t __pyx_t_36; - double __pyx_t_37; + Py_ssize_t __pyx_t_37; Py_ssize_t __pyx_t_38; Py_ssize_t __pyx_t_39; Py_ssize_t __pyx_t_40; - Py_ssize_t __pyx_t_41; __Pyx_RefNannySetupContext("cosine_cols", 0); __pyx_pybuffer_distances.pybuffer.buf = NULL; __pyx_pybuffer_distances.refcount = 0; @@ -7413,43 +7479,43 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 365, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 370, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":367 + /* "Orange/distance/_distance.pyx":372 * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 367, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":368 + /* "Orange/distance/_distance.pyx":373 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, row, col1, col2 */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 368, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":377 + /* "Orange/distance/_distance.pyx":382 * np.ndarray[np.float64_t, ndim=2] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -7461,7 +7527,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":378 + /* "Orange/distance/_distance.pyx":383 * * n_rows, n_cols = x.shape[0], x.shape[1] * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< @@ -7470,26 +7536,26 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); if (__pyx_t_6) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); } if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 378, __pyx_L1_error) + __PYX_ERR(0, 383, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":379 + /* "Orange/distance/_distance.pyx":384 * n_rows, n_cols = x.shape[0], x.shape[1] * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< @@ -7497,34 +7563,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS * for col1 in range(n_cols): */ __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 379, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 384, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 379, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_abss = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":380 + /* "Orange/distance/_distance.pyx":385 * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * if vars[col1] == -2: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); @@ -7532,20 +7598,20 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __pyx_t_1 = 0; __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 380, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 380, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 385, __pyx_L1_error) __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7561,13 +7627,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS } } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 380, __pyx_L1_error) + if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 385, __pyx_L1_error) } __pyx_t_12 = 0; __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":381 + /* "Orange/distance/_distance.pyx":386 * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -7578,7 +7644,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { __pyx_v_col1 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":387 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< @@ -7589,16 +7655,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":383 + /* "Orange/distance/_distance.pyx":388 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); @@ -7606,11 +7672,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_slice__2); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice__2); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 383, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -7618,10 +7684,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __pyx_t_11 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 383, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":384 + /* "Orange/distance/_distance.pyx":389 * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 * continue # <<<<<<<<<<<<<< @@ -7630,7 +7696,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L3_continue; - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":387 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< @@ -7639,7 +7705,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":390 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -7653,7 +7719,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":386 + /* "Orange/distance/_distance.pyx":391 * continue * with nogil: * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -7664,7 +7730,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":392 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7675,7 +7741,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":388 + /* "Orange/distance/_distance.pyx":393 * for col2 in range(col1): * if vars[col2] == -2: * continue # <<<<<<<<<<<<<< @@ -7684,7 +7750,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L11_continue; - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":392 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7693,7 +7759,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":389 + /* "Orange/distance/_distance.pyx":394 * if vars[col2] == -2: * continue * d = 0 # <<<<<<<<<<<<<< @@ -7702,7 +7768,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":390 + /* "Orange/distance/_distance.pyx":395 * continue * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7713,7 +7779,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_row = __pyx_t_23; - /* "Orange/distance/_distance.pyx":391 + /* "Orange/distance/_distance.pyx":396 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -7729,7 +7795,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_val1 = __pyx_t_26; __pyx_v_val2 = __pyx_t_29; - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":397 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7747,7 +7813,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L17_bool_binop_done:; if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":398 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] # <<<<<<<<<<<<<< @@ -7758,7 +7824,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_32 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":397 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7768,7 +7834,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":394 + /* "Orange/distance/_distance.pyx":399 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7778,7 +7844,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":395 + /* "Orange/distance/_distance.pyx":400 * d += means[col1] * means[col2] * elif npy_isnan(val1): * d += val2 * means[col1] # <<<<<<<<<<<<<< @@ -7788,7 +7854,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_33 = __pyx_v_col1; __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":394 + /* "Orange/distance/_distance.pyx":399 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7798,7 +7864,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":401 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7808,7 +7874,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":402 * d += val2 * means[col1] * elif npy_isnan(val2): * d += val1 * means[col2] # <<<<<<<<<<<<<< @@ -7818,7 +7884,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":401 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7828,12 +7894,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":399 + /* "Orange/distance/_distance.pyx":404 * d += val1 * means[col2] * else: * d += val1 * val2 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - d / abss[col1] / abss[col2] + * + * d = 1 - d / abss[col1] / abss[col2] */ /*else*/ { __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); @@ -7841,35 +7907,93 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L16:; } - /* "Orange/distance/_distance.pyx":401 + /* "Orange/distance/_distance.pyx":406 * d += val1 * val2 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< - * return distances * + * d = 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< + * if d < 0: # clip off any numeric errors + * d = 0 */ __pyx_t_35 = __pyx_v_col1; __pyx_t_36 = __pyx_v_col2; - __pyx_t_37 = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); + __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":400 - * else: - * d += val1 * val2 - * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< - * 1 - d / abss[col1] / abss[col2] + /* "Orange/distance/_distance.pyx":407 + * + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: + */ + __pyx_t_6 = ((__pyx_v_d < 0.0) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":408 + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors + * d = 0 # <<<<<<<<<<<<<< + * elif d > 1: + * d = 1 + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":407 + * + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: + */ + goto __pyx_L19; + } + + /* "Orange/distance/_distance.pyx":409 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d + */ + __pyx_t_6 = ((__pyx_v_d > 1.0) != 0); + if (__pyx_t_6) { + + /* "Orange/distance/_distance.pyx":410 + * d = 0 + * elif d > 1: + * d = 1 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d * return distances */ - __pyx_t_38 = __pyx_v_col1; + __pyx_v_d = 1.0; + + /* "Orange/distance/_distance.pyx":409 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d + */ + } + __pyx_L19:; + + /* "Orange/distance/_distance.pyx":411 + * elif d > 1: + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_37 = __pyx_v_col1; + __pyx_t_38 = __pyx_v_col2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; __pyx_t_39 = __pyx_v_col2; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_t_37; - __pyx_t_40 = __pyx_v_col2; - __pyx_t_41 = __pyx_v_col1; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_t_37; + __pyx_t_40 = __pyx_v_col1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; __pyx_L11_continue:; } } - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":390 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -7889,9 +8013,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L3_continue:; } - /* "Orange/distance/_distance.pyx":402 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - d / abss[col1] / abss[col2] + /* "Orange/distance/_distance.pyx":412 + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< * * @@ -7901,7 +8025,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":365 + /* "Orange/distance/_distance.pyx":370 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -7940,7 +8064,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":405 +/* "Orange/distance/_distance.pyx":415 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -7982,21 +8106,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 405, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 415, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 405, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 415, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 405, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 415, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 405, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 415, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -8008,19 +8132,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 405, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 415, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 405, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 406, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 415, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 416, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -8092,32 +8216,32 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 405, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 415, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 405, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 415, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":410 + /* "Orange/distance/_distance.pyx":420 * fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 410, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 410, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":417 + /* "Orange/distance/_distance.pyx":427 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -8129,7 +8253,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":418 + /* "Orange/distance/_distance.pyx":428 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -8138,7 +8262,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":419 + /* "Orange/distance/_distance.pyx":429 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< @@ -8153,28 +8277,28 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 419, __pyx_L1_error) + __PYX_ERR(0, 429, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":421 + /* "Orange/distance/_distance.pyx":431 * assert n_cols == x2.shape[1] == ps.shape[0] * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -8182,27 +8306,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 421, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 421, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":422 + /* "Orange/distance/_distance.pyx":432 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8216,7 +8340,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":423 + /* "Orange/distance/_distance.pyx":433 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -8227,7 +8351,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_row1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":424 + /* "Orange/distance/_distance.pyx":434 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -8242,7 +8366,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":425 + /* "Orange/distance/_distance.pyx":435 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 # <<<<<<<<<<<<<< @@ -8252,7 +8376,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_intersection = 0.0; __pyx_v_union = 0.0; - /* "Orange/distance/_distance.pyx":426 + /* "Orange/distance/_distance.pyx":436 * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -8263,7 +8387,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":427 + /* "Orange/distance/_distance.pyx":437 * intersection = union = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -8279,7 +8403,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":428 + /* "Orange/distance/_distance.pyx":438 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8289,7 +8413,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":439 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8299,7 +8423,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":430 + /* "Orange/distance/_distance.pyx":440 * if npy_isnan(val1): * if npy_isnan(val2): * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< @@ -8309,7 +8433,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_22 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); - /* "Orange/distance/_distance.pyx":431 + /* "Orange/distance/_distance.pyx":441 * if npy_isnan(val2): * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< @@ -8319,7 +8443,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_23 = __pyx_v_col; __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":439 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8329,7 +8453,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":432 + /* "Orange/distance/_distance.pyx":442 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8339,7 +8463,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":433 + /* "Orange/distance/_distance.pyx":443 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8349,7 +8473,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_24 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":434 + /* "Orange/distance/_distance.pyx":444 * elif val2 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8358,7 +8482,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":432 + /* "Orange/distance/_distance.pyx":442 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8368,7 +8492,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":436 + /* "Orange/distance/_distance.pyx":446 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8381,7 +8505,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L13:; - /* "Orange/distance/_distance.pyx":428 + /* "Orange/distance/_distance.pyx":438 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8391,7 +8515,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":447 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8401,7 +8525,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":448 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8411,7 +8535,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":449 * elif npy_isnan(val2): * if val1 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8421,7 +8545,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_26 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":450 * if val1 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8430,7 +8554,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":448 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8440,7 +8564,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":442 + /* "Orange/distance/_distance.pyx":452 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8453,7 +8577,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L14:; - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":447 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8463,7 +8587,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":444 + /* "Orange/distance/_distance.pyx":454 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8482,7 +8606,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L16_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":445 + /* "Orange/distance/_distance.pyx":455 * else: * if val1 != 0 and val2 != 0: * intersection += 1 # <<<<<<<<<<<<<< @@ -8491,7 +8615,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":444 + /* "Orange/distance/_distance.pyx":454 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8500,7 +8624,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":456 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8518,7 +8642,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L19_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":457 * intersection += 1 * if val1 != 0 or val2 != 0: * union += 1 # <<<<<<<<<<<<<< @@ -8527,7 +8651,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":456 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8539,7 +8663,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L12:; } - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":458 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8549,7 +8673,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":459 * union += 1 * if union != 0: * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< @@ -8560,7 +8684,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_30 = __pyx_v_row2; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":458 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8572,7 +8696,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":422 + /* "Orange/distance/_distance.pyx":432 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8590,7 +8714,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":451 + /* "Orange/distance/_distance.pyx":461 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8600,7 +8724,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":452 + /* "Orange/distance/_distance.pyx":462 * * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -8609,7 +8733,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":451 + /* "Orange/distance/_distance.pyx":461 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8618,7 +8742,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":453 + /* "Orange/distance/_distance.pyx":463 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -8626,13 +8750,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":405 + /* "Orange/distance/_distance.pyx":415 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -8669,7 +8793,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":456 +/* "Orange/distance/_distance.pyx":466 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -8707,11 +8831,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 456, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 466, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 456, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 466, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -8724,13 +8848,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 456, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 466, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 456, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 466, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -8805,27 +8929,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 456, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 466, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":458 + /* "Orange/distance/_distance.pyx":468 * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 458, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":465 + /* "Orange/distance/_distance.pyx":475 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -8837,23 +8961,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":476 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); @@ -8861,27 +8985,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 466, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 466, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":477 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -8892,7 +9016,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col1 = __pyx_t_10; - /* "Orange/distance/_distance.pyx":468 + /* "Orange/distance/_distance.pyx":478 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -8903,7 +9027,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_col2 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":469 + /* "Orange/distance/_distance.pyx":479 * for col1 in range(n_cols): * for col2 in range(col1): * in_both = in_one = 0 # <<<<<<<<<<<<<< @@ -8913,7 +9037,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_one = 0; - /* "Orange/distance/_distance.pyx":470 + /* "Orange/distance/_distance.pyx":480 * for col2 in range(col1): * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< @@ -8926,7 +9050,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_unk1_not2 = 0; __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":471 + /* "Orange/distance/_distance.pyx":481 * in_both = in_one = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -8937,7 +9061,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_row = __pyx_t_14; - /* "Orange/distance/_distance.pyx":472 + /* "Orange/distance/_distance.pyx":482 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -8953,7 +9077,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_v_val1 = __pyx_t_17; __pyx_v_val2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":473 + /* "Orange/distance/_distance.pyx":483 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8963,7 +9087,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":474 + /* "Orange/distance/_distance.pyx":484 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8973,7 +9097,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":475 + /* "Orange/distance/_distance.pyx":485 * if npy_isnan(val1): * if npy_isnan(val2): * unk1_unk2 += 1 # <<<<<<<<<<<<<< @@ -8982,7 +9106,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":474 + /* "Orange/distance/_distance.pyx":484 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8992,7 +9116,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":486 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -9002,7 +9126,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":477 + /* "Orange/distance/_distance.pyx":487 * unk1_unk2 += 1 * elif val2 != 0: * unk1_in2 += 1 # <<<<<<<<<<<<<< @@ -9011,7 +9135,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":486 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -9021,7 +9145,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L10; } - /* "Orange/distance/_distance.pyx":479 + /* "Orange/distance/_distance.pyx":489 * unk1_in2 += 1 * else: * unk1_not2 += 1 # <<<<<<<<<<<<<< @@ -9033,7 +9157,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } __pyx_L10:; - /* "Orange/distance/_distance.pyx":473 + /* "Orange/distance/_distance.pyx":483 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -9043,7 +9167,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":480 + /* "Orange/distance/_distance.pyx":490 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9053,7 +9177,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":491 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -9063,7 +9187,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":482 + /* "Orange/distance/_distance.pyx":492 * elif npy_isnan(val2): * if val1 != 0: * in1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9072,7 +9196,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":491 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -9082,7 +9206,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":484 + /* "Orange/distance/_distance.pyx":494 * in1_unk2 += 1 * else: * not1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9094,7 +9218,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } __pyx_L11:; - /* "Orange/distance/_distance.pyx":480 + /* "Orange/distance/_distance.pyx":490 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9104,7 +9228,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L9; } - /* "Orange/distance/_distance.pyx":486 + /* "Orange/distance/_distance.pyx":496 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -9123,7 +9247,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L13_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":487 + /* "Orange/distance/_distance.pyx":497 * else: * if val1 != 0 and val2 != 0: * in_both += 1 # <<<<<<<<<<<<<< @@ -9132,7 +9256,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + 1); - /* "Orange/distance/_distance.pyx":486 + /* "Orange/distance/_distance.pyx":496 * not1_unk2 += 1 * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -9142,7 +9266,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":488 + /* "Orange/distance/_distance.pyx":498 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -9160,7 +9284,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L15_bool_binop_done:; if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":489 + /* "Orange/distance/_distance.pyx":499 * in_both += 1 * elif val1 != 0 or val2 != 0: * in_one += 1 # <<<<<<<<<<<<<< @@ -9169,7 +9293,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_v_in_one = (__pyx_v_in_one + 1); - /* "Orange/distance/_distance.pyx":488 + /* "Orange/distance/_distance.pyx":498 * if val1 != 0 and val2 != 0: * in_both += 1 * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -9182,7 +9306,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_L9:; } - /* "Orange/distance/_distance.pyx":492 + /* "Orange/distance/_distance.pyx":502 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< @@ -9191,7 +9315,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_23 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":493 + /* "Orange/distance/_distance.pyx":503 * 1 - float(in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -9200,7 +9324,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_24 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":494 + /* "Orange/distance/_distance.pyx":504 * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< @@ -9210,7 +9334,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_25 = __pyx_v_col1; __pyx_t_26 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":496 + /* "Orange/distance/_distance.pyx":506 * + ps[col1] * ps[col2] * unk1_unk2) / \ * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< @@ -9219,7 +9343,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_27 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":497 + /* "Orange/distance/_distance.pyx":507 * (in_both + in_one + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< @@ -9228,7 +9352,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":498 + /* "Orange/distance/_distance.pyx":508 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< @@ -9237,7 +9361,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_t_29 = __pyx_v_col1; __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":491 + /* "Orange/distance/_distance.pyx":501 * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both # <<<<<<<<<<<<<< @@ -9246,7 +9370,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU */ __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - /* "Orange/distance/_distance.pyx":490 + /* "Orange/distance/_distance.pyx":500 * elif val1 != 0 or val2 != 0: * in_one += 1 * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -9262,19 +9386,19 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":499 + /* "Orange/distance/_distance.pyx":509 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":456 + /* "Orange/distance/_distance.pyx":466 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -23856,17 +23980,17 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "Orange/distance/_distance.pyx":383 + /* "Orange/distance/_distance.pyx":388 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); - __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -24154,41 +24278,41 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__33); __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 288, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 288, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":365 + /* "Orange/distance/_distance.pyx":370 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] vars = fit_params["vars"] */ - __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 365, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 370, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":405 + /* "Orange/distance/_distance.pyx":415 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 405, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 405, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 405, __pyx_L1_error) + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 415, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 415, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":456 + /* "Orange/distance/_distance.pyx":466 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 456, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39); - __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 456, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 456, __pyx_L1_error) + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 466, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 466, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -24486,40 +24610,40 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":365 + /* "Orange/distance/_distance.pyx":370 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] vars = fit_params["vars"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":405 + /* "Orange/distance/_distance.pyx":415 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 405, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":456 + /* "Orange/distance/_distance.pyx":466 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 456, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index a573bf1ab5c..0e7226c0b11 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -330,7 +330,12 @@ def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, d += val1 * means[col] else: d += val1 * val2 - distances[row1, row2] = 1 - d / abs1[row1] / abs2[row2] + d = 1 - d / abs1[row1] / abs2[row2] + if d < 0: # clip off any numeric errors + d = 0 + elif d > 1: + d = 1 + distances[row1, row2] = d if not two_tables: _lower_to_symmetric(distances) return distances @@ -397,8 +402,13 @@ def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): d += val1 * means[col2] else: d += val1 * val2 - distances[col1, col2] = distances[col2, col1] = \ - 1 - d / abss[col1] / abss[col2] + + d = 1 - d / abss[col1] / abss[col2] + if d < 0: # clip off any numeric errors + d = 0 + elif d > 1: + d = 1 + distances[col1, col2] = distances[col2, col1] = d return distances From 09aca0529c796d10008610a236ef18d6cfcab44d Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 22:58:47 +0200 Subject: [PATCH 10/27] distances: Refactor checks in OWDistances --- Orange/widgets/unsupervised/owdistances.py | 82 +++++++++------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/Orange/widgets/unsupervised/owdistances.py b/Orange/widgets/unsupervised/owdistances.py index 90e00aeee60..3fe41cdf105 100644 --- a/Orange/widgets/unsupervised/owdistances.py +++ b/Orange/widgets/unsupervised/owdistances.py @@ -1,5 +1,6 @@ from AnyQt.QtCore import Qt from scipy.sparse import issparse +import bottleneck as bn import Orange.data import Orange.misc @@ -42,15 +43,13 @@ class Outputs: class Error(OWWidget.Error): no_continuous_features = Msg("No numeric features") - dense_metric_sparse_data = Msg("Selected metric does not support sparse data") - empty_data = Msg("Empty data set") - mahalanobis_error = Msg("{}") - distances_memory_error = Msg("Not enough memory.") - distances_value_error = Msg("Error occurred while calculating distances\n{}") + dense_metric_sparse_data = Msg("{} requires dense data.") + distances_memory_error = Msg("Not enough memory") + distances_value_error = Msg("Problem in calculation:\n{}") class Warning(OWWidget.Warning): ignoring_discrete = Msg("Ignoring categorical features") - imputing_data = Msg("Imputing missing values") + imputing_data = Msg("Missing values were imputed") def __init__(self): super().__init__() @@ -75,78 +74,65 @@ def __init__(self): @Inputs.data @check_sql_input def set_data(self, data): - """ - Set the input data set from which to compute the distances - """ self.data = data self.refresh_metrics() self.unconditional_commit() def refresh_metrics(self): - """ - Refresh available metrics depending on the input data's sparsenes - """ sparse = self.data is not None and issparse(self.data.X) for i, metric in enumerate(METRICS): item = self.metrics_combo.model().item(i) item.setEnabled(not sparse or metric[1].supports_sparse) - self._checksparse() - - def _checksparse(self): - # Check the current metric for input data compatibility and set/clear - # appropriate informational GUI state - self.Error.dense_metric_sparse_data( - shown=self.data is not None and issparse(self.data.X) and - not METRICS[self.metric_idx][1].supports_sparse) - def commit(self): + # pylint: disable=invalid-sequence-index metric = METRICS[self.metric_idx][1] dist = self.compute_distances(metric, self.data) self.Outputs.distances.send(dist) def compute_distances(self, metric, data): - def checks(metric, data): - if data is None: - return - if issparse(data.X): - if not metric.supports_sparse: - self.Error.dense_metric_sparse_data() - return - remove_discrete = metric.fallback is not None \ - and self.data.domain.has_discrete_attributes() - else: # not sparse - remove_discrete = \ - not metric.supports_discrete or self.axis == 1 \ - and self.data.domain.has_discrete_attributes() - if remove_discrete: - data = distance._preprocess(data, impute=False) - if data.X.size: - self.Warning.ignoring_discrete() - if not data.X.size: - self.Error.empty_data() - return - return data + def _check_sparse(): + # pylint: disable=invalid-sequence-index + if issparse(data.X) and not metric.supports_sparse: + self.Error.dense_metric_sparse_data(METRICS[self.metric_idx][0]) + return False + + def _fix_discrete(): + nonlocal data + if data.domain.has_discrete_attributes() and ( + issparse(data.X) and getattr(metric, "fallback", None) + or not metric.supports_discrete + or self.axis == 1): + if not data.domain.has_continuous_attributes(): + self.Error.no_continuous_features() + return False + self.Warning.ignoring_discrete() + data = distance.remove_discrete_features(data) + + def _fix_missing(): + nonlocal data + if not metric.supports_missing and bn.anynan(data.X): + self.Warning.imputing_data() + data = distance.impute(data) self.clear_messages() - data = checks(metric, data) if data is None: return + for check in (_check_sparse, _fix_discrete, _fix_missing): + if check() is False: + return try: - met = metric(data, data, 1 - self.axis, impute=True) + return metric(data, axis=1 - self.axis, impute=True) except ValueError as e: self.Error.distances_value_error(e) - return except MemoryError: self.Error.distances_memory_error() - return - return met def _invalidate(self): - self._checksparse() self.commit() def send_report(self): + # pylint: disable=invalid-sequence-index self.report_items(( ("Distances Between", ["Rows", "Columns"][self.axis]), ("Metric", METRICS[self.metric_idx][0]) From bee0112d43c497a6af9d509b54c85ba6b2c903a1 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 23:14:49 +0200 Subject: [PATCH 11/27] util: fix nanmean and nanvar --- Orange/statistics/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orange/statistics/util.py b/Orange/statistics/util.py index 8d97ac85f52..478128a2f26 100644 --- a/Orange/statistics/util.py +++ b/Orange/statistics/util.py @@ -294,7 +294,7 @@ def _apply_func(x, dense_func, sparse_func, axis=None): arr = x if axis == 1 else x.T arr = arr.tocsr() return np.fromiter((sparse_func(row) for row in arr), - dtype=np.double, count=len(arr)) + dtype=np.double, count=arr.shape[0]) else: raise NotImplementedError From 00dde91caa79361161df69726eac0a66c8b0f138 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 23:15:15 +0200 Subject: [PATCH 12/27] manifold.py: update to use new distances --- Orange/projection/manifold.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Orange/projection/manifold.py b/Orange/projection/manifold.py index 0aa36f2f3c5..e55248aed8d 100644 --- a/Orange/projection/manifold.py +++ b/Orange/projection/manifold.py @@ -1,8 +1,7 @@ import numpy as np import sklearn.manifold as skl_manifold -from Orange.distance import (SklDistance, SpearmanDistance, PearsonDistance, - Euclidean) +from Orange.distance import Distance, DistanceModel, Euclidean from Orange.projection import SklProjector __all__ = ["MDS", "Isomap", "LocallyLinearEmbedding", "SpectralEmbedding", @@ -60,8 +59,9 @@ def __init__(self, n_components=2, metric=True, n_init=4, max_iter=300, def __call__(self, data): params = self.params.copy() dissimilarity = params['dissimilarity'] - distances = SklDistance, SpearmanDistance, PearsonDistance - if isinstance(self._metric, distances): + if isinstance(self._metric, DistanceModel) \ + or (isinstance(self._metric, type) + and issubclass(self._metric, Distance)): data = self.preprocess(data) _X, Y, domain = data.X, data.Y, data.domain X = dist_matrix = self._metric(_X) @@ -147,8 +147,7 @@ def __call__(self, data): else: data = self.preprocess(data) X, Y, domain = data.X, data.Y, data.domain - distances = SklDistance, SpearmanDistance, PearsonDistance - if isinstance(metric, distances): + if isinstance(metric, Distance): X = metric(X) params['metric'] = 'precomputed' From 2f0ffce6767045867a972b5bade82ce7c3457510 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 13 Jul 2017 23:19:30 +0200 Subject: [PATCH 13/27] distances: Add nogil where possible --- Orange/distance/_distance.c | 2841 +++++++++++++++++---------------- Orange/distance/_distance.pyx | 179 ++- 2 files changed, 1561 insertions(+), 1459 deletions(-) diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index 8c9d4489fe2..8daec239199 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -4328,8 +4328,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * == len(dist_missing) == len(dist_missing2) * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): + * with nogil: + * for row1 in range(n_rows1): */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -4371,443 +4371,476 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN /* "Orange/distance/_distance.pyx":160 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_15 = __pyx_v_n_rows1; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_row1 = __pyx_t_16; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":161 + /* "Orange/distance/_distance.pyx":161 * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 */ - if ((__pyx_v_two_tables != 0)) { - __pyx_t_17 = __pyx_v_n_rows2; - } else { - __pyx_t_17 = __pyx_v_row1; - } - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { - __pyx_v_row2 = __pyx_t_18; + __pyx_t_15 = __pyx_v_n_rows1; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":162 - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if mads[col] == -2: + /* "Orange/distance/_distance.pyx":162 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_two_tables != 0)) { + __pyx_t_17 = __pyx_v_n_rows2; + } else { + __pyx_t_17 = __pyx_v_row1; + } + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { + __pyx_v_row2 = __pyx_t_18; + + /* "Orange/distance/_distance.pyx":163 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if mads[col] == -2: */ - __pyx_v_d = 0.0; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":163 - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if mads[col] == -2: - * continue + /* "Orange/distance/_distance.pyx":164 + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if mads[col] == -2: + * continue */ - __pyx_t_19 = __pyx_v_n_cols; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col = __pyx_t_20; + __pyx_t_19 = __pyx_v_n_cols; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":164 - * d = 0 - * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue + /* "Orange/distance/_distance.pyx":165 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue * */ - __pyx_t_21 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_7) { + __pyx_t_21 = __pyx_v_col; + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":165 - * for col in range(n_cols): - * if mads[col] == -2: - * continue # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":166 + * for col in range(n_cols): + * if mads[col] == -2: + * continue # <<<<<<<<<<<<<< * - * val1, val2 = x1[row1, col], x2[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] */ - goto __pyx_L7_continue; + goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":164 - * d = 0 - * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue + /* "Orange/distance/_distance.pyx":165 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue * */ - } + } - /* "Orange/distance/_distance.pyx":167 - * continue + /* "Orange/distance/_distance.pyx":168 + * continue * - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] */ - __pyx_t_22 = __pyx_v_row1; - __pyx_t_23 = __pyx_v_col; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_25 = __pyx_v_row2; - __pyx_t_26 = __pyx_v_col; - __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_24; - __pyx_v_val2 = __pyx_t_27; + __pyx_t_22 = __pyx_v_row1; + __pyx_t_23 = __pyx_v_col; + __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_25 = __pyx_v_row2; + __pyx_t_26 = __pyx_v_col; + __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_24; + __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":169 * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: */ - __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_7 = __pyx_t_28; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_7 = __pyx_t_28; - __pyx_L11_bool_binop_done:; - if (__pyx_t_7) { + __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_7 = __pyx_t_28; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_7 = __pyx_t_28; + __pyx_L14_bool_binop_done:; + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":169 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) + /* "Orange/distance/_distance.pyx":170 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) */ - __pyx_t_29 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); + __pyx_t_29 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":169 * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: */ - goto __pyx_L10; - } + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":170 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":171 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): */ - __pyx_t_30 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_7) { + __pyx_t_30 = __pyx_v_col; + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":171 - * d += dist_missing2[col] - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += dist_missing[col, ival2] + /* "Orange/distance/_distance.pyx":172 + * d += dist_missing2[col] + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += dist_missing[col, ival2] */ - __pyx_v_ival1 = ((int)__pyx_v_val1); - __pyx_v_ival2 = ((int)__pyx_v_val2); + __pyx_v_ival1 = ((int)__pyx_v_val1); + __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":172 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":173 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":173 - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] + /* "Orange/distance/_distance.pyx":174 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] */ - __pyx_t_31 = __pyx_v_col; - __pyx_t_32 = __pyx_v_ival2; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); + __pyx_t_31 = __pyx_v_col; + __pyx_t_32 = __pyx_v_ival2; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":172 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":173 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): */ - goto __pyx_L13; - } + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":174 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + /* "Orange/distance/_distance.pyx":175 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":175 - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< - * elif ival1 != ival2: - * d += 1 + /* "Orange/distance/_distance.pyx":176 + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< + * elif ival1 != ival2: + * d += 1 */ - __pyx_t_33 = __pyx_v_col; - __pyx_t_34 = __pyx_v_ival1; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); + __pyx_t_33 = __pyx_v_col; + __pyx_t_34 = __pyx_v_ival1; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":174 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + /* "Orange/distance/_distance.pyx":175 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - goto __pyx_L13; - } + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":176 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: + /* "Orange/distance/_distance.pyx":177 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: */ - __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_7) { + __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":177 - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - * d += 1 # <<<<<<<<<<<<<< - * elif normalize: - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":178 + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + * d += 1 # <<<<<<<<<<<<<< + * elif normalize: + * if npy_isnan(val1): */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":176 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: + /* "Orange/distance/_distance.pyx":177 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: */ - } - __pyx_L13:; + } + __pyx_L16:; - /* "Orange/distance/_distance.pyx":170 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":171 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): */ - goto __pyx_L10; - } + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":178 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":179 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_7 = (__pyx_v_normalize != 0); - if (__pyx_t_7) { + __pyx_t_7 = (__pyx_v_normalize != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":179 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":180 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":180 - * elif normalize: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":181 + * elif normalize: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_35 = __pyx_v_col; - __pyx_t_36 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + __pyx_t_35 = __pyx_v_col; + __pyx_t_36 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":179 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":180 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): */ - goto __pyx_L14; - } + goto __pyx_L17; + } - /* "Orange/distance/_distance.pyx":181 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":182 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + */ + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { + + /* "Orange/distance/_distance.pyx":183 + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) / mads[col] / 2 + */ + __pyx_t_37 = __pyx_v_col; + __pyx_t_38 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":182 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + */ + goto __pyx_L17; + } + + /* "Orange/distance/_distance.pyx":185 + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< * else: + * if npy_isnan(val1): + */ + /*else*/ { + __pyx_t_39 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); + } + __pyx_L17:; + + /* "Orange/distance/_distance.pyx":179 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":182 - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":187 + * d += fabs(val1 - val2) / mads[col] / 2 * else: - * d += fabs(val1 - val2) / mads[col] / 2 + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): */ - __pyx_t_37 = __pyx_v_col; - __pyx_t_38 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + /*else*/ { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":181 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":188 * else: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] */ - goto __pyx_L14; - } + __pyx_t_40 = __pyx_v_col; + __pyx_t_41 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":184 - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":187 + * d += fabs(val1 - val2) / mads[col] / 2 * else: - * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): - */ - /*else*/ { - __pyx_t_39 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); - } - __pyx_L14:; - - /* "Orange/distance/_distance.pyx":178 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - */ - goto __pyx_L10; - } - - /* "Orange/distance/_distance.pyx":186 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - */ - /*else*/ { - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":187 - * else: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): */ - __pyx_t_40 = __pyx_v_col; - __pyx_t_41 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); + goto __pyx_L18; + } - /* "Orange/distance/_distance.pyx":186 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":189 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: */ - goto __pyx_L15; - } + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":188 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: + /* "Orange/distance/_distance.pyx":190 + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + __pyx_t_42 = __pyx_v_col; + __pyx_t_43 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":189 - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) + /* "Orange/distance/_distance.pyx":189 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: */ - __pyx_t_42 = __pyx_v_col; - __pyx_t_43 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); + goto __pyx_L18; + } - /* "Orange/distance/_distance.pyx":188 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: + /* "Orange/distance/_distance.pyx":192 + * d += fabs(val1 - medians[col]) + mads[col] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * + * distances[row1, row2] = d */ - goto __pyx_L15; - } + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L18:; + } + __pyx_L13:; + __pyx_L10_continue:; + } - /* "Orange/distance/_distance.pyx":191 - * d += fabs(val1 - medians[col]) + mads[col] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":194 + * d += fabs(val1 - val2) + * + * distances[row1, row2] = d # <<<<<<<<<<<<<< * - * distances[row1, row2] = d + * if not two_tables: */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + __pyx_t_44 = __pyx_v_row1; + __pyx_t_45 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } - __pyx_L15:; } - __pyx_L10:; - __pyx_L7_continue:; } - /* "Orange/distance/_distance.pyx":193 - * d += fabs(val1 - val2) - * - * distances[row1, row2] = d # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":160 * - * if not two_tables: + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_44 = __pyx_v_row1; - __pyx_t_45 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } } - /* "Orange/distance/_distance.pyx":195 - * distances[row1, row2] = d + /* "Orange/distance/_distance.pyx":196 + * distances[row1, row2] = d * * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) @@ -4816,7 +4849,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":196 + /* "Orange/distance/_distance.pyx":197 * * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -4825,8 +4858,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":195 - * distances[row1, row2] = d + /* "Orange/distance/_distance.pyx":196 + * distances[row1, row2] = d * * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) @@ -4834,7 +4867,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN */ } - /* "Orange/distance/_distance.pyx":197 + /* "Orange/distance/_distance.pyx":198 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -4842,7 +4875,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4888,7 +4921,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":200 +/* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -4926,11 +4959,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 200, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 201, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 200, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 201, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4943,13 +4976,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 200, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 201, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -5023,84 +5056,84 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 200, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 201, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":202 + /* "Orange/distance/_distance.pyx":203 * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 202, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_medians = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":203 + /* "Orange/distance/_distance.pyx":204 * cdef: * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< * char normalize = fit_params["normalize"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mads = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":204 + /* "Orange/distance/_distance.pyx":205 * double [:] medians = fit_params["medians"] * double [:] mads = fit_params["mads"] * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_normalize = __pyx_t_3; - /* "Orange/distance/_distance.pyx":210 + /* "Orange/distance/_distance.pyx":211 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): + * with nogil: */ __pyx_t_4 = (__pyx_v_x->dimensions[0]); __pyx_t_5 = (__pyx_v_x->dimensions[1]); __pyx_v_n_rows = __pyx_t_4; __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":212 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * with nogil: + * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -5108,389 +5141,422 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 211, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":212 + /* "Orange/distance/_distance.pyx":213 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * d = 0 + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ - __pyx_t_10 = __pyx_v_n_cols; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_col1 = __pyx_t_11; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":214 * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): + * with nogil: + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * d = 0 */ - __pyx_t_12 = __pyx_v_col1; - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_col2 = __pyx_t_13; + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":214 - * for col1 in range(n_cols): - * for col2 in range(col1): - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":215 + * with nogil: + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - __pyx_v_d = 0.0; + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":215 - * for col2 in range(col1): - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: + /* "Orange/distance/_distance.pyx":216 + * for col1 in range(n_cols): + * for col2 in range(col1): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":216 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col1; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row; - __pyx_t_20 = __pyx_v_col2; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; - - /* "Orange/distance/_distance.pyx":217 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - */ - __pyx_t_22 = (__pyx_v_normalize != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":218 - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":217 + * for col2 in range(col1): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: */ - __pyx_t_23 = __pyx_v_col1; - __pyx_t_24 = __pyx_v_col1; - __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":219 - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + /* "Orange/distance/_distance.pyx":218 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) */ - __pyx_t_25 = __pyx_v_col2; - __pyx_t_26 = __pyx_v_col2; - __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col1; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":220 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += 1 + /* "Orange/distance/_distance.pyx":219 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) */ - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { + __pyx_t_22 = (__pyx_v_normalize != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":221 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":220 + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_23 = __pyx_v_col1; + __pyx_t_24 = __pyx_v_col1; + __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":222 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += 1 # <<<<<<<<<<<<<< - * else: - * d += fabs(val2) + 0.5 + /* "Orange/distance/_distance.pyx":221 + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_25 = __pyx_v_col2; + __pyx_t_26 = __pyx_v_col2; + __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":222 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":223 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":224 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += fabs(val2) + 0.5 + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":223 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":226 + * d += 1 + * else: + * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":222 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 */ - __pyx_v_d = (__pyx_v_d + 1.0); + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":221 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + /* "Orange/distance/_distance.pyx":227 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 * else: */ - goto __pyx_L11; - } + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":224 - * d += 1 + /* "Orange/distance/_distance.pyx":228 + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< * else: - * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 + * d += fabs(val1 - val2) */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); - } - __pyx_L11:; + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":220 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += 1 + /* "Orange/distance/_distance.pyx":227 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: */ - goto __pyx_L10; - } + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":225 + /* "Orange/distance/_distance.pyx":230 + * d += fabs(val1) + 0.5 * else: - * d += fabs(val2) + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< * else: + * if npy_isnan(val1): */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L13:; - /* "Orange/distance/_distance.pyx":226 - * d += fabs(val2) + 0.5 - * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) + /* "Orange/distance/_distance.pyx":219 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) */ - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":225 - * else: - * d += fabs(val2) + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + /* "Orange/distance/_distance.pyx":232 + * d += fabs(val1 - val2) * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ */ - goto __pyx_L10; - } + /*else*/ { + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":228 - * d += fabs(val1) + 0.5 + /* "Orange/distance/_distance.pyx":233 * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); - } - __pyx_L10:; - - /* "Orange/distance/_distance.pyx":217 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) */ - goto __pyx_L9; - } + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":230 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ + /* "Orange/distance/_distance.pyx":234 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: */ - /*else*/ { - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { + __pyx_t_27 = __pyx_v_col1; + __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":231 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) + /* "Orange/distance/_distance.pyx":235 + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":232 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: + /* "Orange/distance/_distance.pyx":234 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: */ - __pyx_t_27 = __pyx_v_col1; - __pyx_t_28 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); - /* "Orange/distance/_distance.pyx":233 - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] + /* "Orange/distance/_distance.pyx":233 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":232 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: + /* "Orange/distance/_distance.pyx":237 + * + fabs(medians[col1] - medians[col2]) + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] */ - __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); + /*else*/ { + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); + } + __pyx_L16:; - /* "Orange/distance/_distance.pyx":231 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) + /* "Orange/distance/_distance.pyx":232 + * d += fabs(val1 - val2) + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ */ - goto __pyx_L13; - } + goto __pyx_L15; + } - /* "Orange/distance/_distance.pyx":235 - * + fabs(medians[col1] - medians[col2]) + /* "Orange/distance/_distance.pyx":238 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] * else: - * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] - */ - /*else*/ { - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); - } - __pyx_L13:; - - /* "Orange/distance/_distance.pyx":230 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ */ - goto __pyx_L12; - } + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":239 + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: + * d += fabs(val1 - val2) */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_33 = __pyx_v_col2; + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":237 - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) + /* "Orange/distance/_distance.pyx":238 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: */ - __pyx_t_33 = __pyx_v_col2; - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); + goto __pyx_L15; + } - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":241 + * d += fabs(val1 - medians[col2]) + mads[col2] * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return distances */ - goto __pyx_L12; - } + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L15:; + } + __pyx_L12:; + } - /* "Orange/distance/_distance.pyx":239 - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d + /* "Orange/distance/_distance.pyx":242 + * else: + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< * return distances + * */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + __pyx_t_37 = __pyx_v_col2; + __pyx_t_38 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } - __pyx_L12:; } - __pyx_L9:; } - /* "Orange/distance/_distance.pyx":240 - * else: - * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return distances - * + /* "Orange/distance/_distance.pyx":213 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - __pyx_t_37 = __pyx_v_col2; - __pyx_t_38 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } } - /* "Orange/distance/_distance.pyx":241 - * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d + /* "Orange/distance/_distance.pyx":243 + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -5526,7 +5592,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN return __pyx_r; } -/* "Orange/distance/_distance.pyx":244 +/* "Orange/distance/_distance.pyx":246 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -5542,7 +5608,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__py PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 244, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 246, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ @@ -5575,11 +5641,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 244, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":249 + /* "Orange/distance/_distance.pyx":251 * double val * * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< @@ -5589,18 +5655,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_v_nonzeros = 0; __pyx_v_nonnans = 0; - /* "Orange/distance/_distance.pyx":250 + /* "Orange/distance/_distance.pyx":252 * * nonzeros = nonnans = 0 * for row in range(len(x)): # <<<<<<<<<<<<<< * val = x[row] * if not npy_isnan(val): */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 252, __pyx_L1_error) for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":251 + /* "Orange/distance/_distance.pyx":253 * nonzeros = nonnans = 0 * for row in range(len(x)): * val = x[row] # <<<<<<<<<<<<<< @@ -5610,7 +5676,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_3 = __pyx_v_row; __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - /* "Orange/distance/_distance.pyx":252 + /* "Orange/distance/_distance.pyx":254 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -5620,7 +5686,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":253 + /* "Orange/distance/_distance.pyx":255 * val = x[row] * if not npy_isnan(val): * nonnans += 1 # <<<<<<<<<<<<<< @@ -5629,7 +5695,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ __pyx_v_nonnans = (__pyx_v_nonnans + 1); - /* "Orange/distance/_distance.pyx":254 + /* "Orange/distance/_distance.pyx":256 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -5639,7 +5705,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":255 + /* "Orange/distance/_distance.pyx":257 * nonnans += 1 * if val != 0: * nonzeros += 1 # <<<<<<<<<<<<<< @@ -5648,7 +5714,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - /* "Orange/distance/_distance.pyx":254 + /* "Orange/distance/_distance.pyx":256 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -5657,7 +5723,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED */ } - /* "Orange/distance/_distance.pyx":252 + /* "Orange/distance/_distance.pyx":254 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -5667,7 +5733,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED } } - /* "Orange/distance/_distance.pyx":256 + /* "Orange/distance/_distance.pyx":258 * if val != 0: * nonzeros += 1 * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< @@ -5675,13 +5741,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":246 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -5709,7 +5775,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED return __pyx_r; } -/* "Orange/distance/_distance.pyx":259 +/* "Orange/distance/_distance.pyx":261 * * * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -5750,7 +5816,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli Py_ssize_t __pyx_t_21; __Pyx_RefNannySetupContext("_abs_rows", 0); - /* "Orange/distance/_distance.pyx":265 + /* "Orange/distance/_distance.pyx":267 * int row, col, n_rows, n_cols * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -5762,19 +5828,19 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":266 + /* "Orange/distance/_distance.pyx":268 * * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) # <<<<<<<<<<<<<< * with nogil: * for row in range(n_rows): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { @@ -5787,29 +5853,29 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 266, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":267 + /* "Orange/distance/_distance.pyx":269 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) * with nogil: # <<<<<<<<<<<<<< @@ -5823,7 +5889,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":270 * abss = np.empty(n_rows) * with nogil: * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -5834,7 +5900,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_row = __pyx_t_10; - /* "Orange/distance/_distance.pyx":269 + /* "Orange/distance/_distance.pyx":271 * with nogil: * for row in range(n_rows): * d = 0 # <<<<<<<<<<<<<< @@ -5843,7 +5909,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":270 + /* "Orange/distance/_distance.pyx":272 * for row in range(n_rows): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -5854,7 +5920,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_col = __pyx_t_12; - /* "Orange/distance/_distance.pyx":271 + /* "Orange/distance/_distance.pyx":273 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -5865,7 +5931,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":272 + /* "Orange/distance/_distance.pyx":274 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -5874,7 +5940,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ goto __pyx_L8_continue; - /* "Orange/distance/_distance.pyx":271 + /* "Orange/distance/_distance.pyx":273 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -5883,7 +5949,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ } - /* "Orange/distance/_distance.pyx":273 + /* "Orange/distance/_distance.pyx":275 * if vars[col] == -2: * continue * val = x[row, col] # <<<<<<<<<<<<<< @@ -5894,7 +5960,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_16 = __pyx_v_col; __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":274 + /* "Orange/distance/_distance.pyx":276 * continue * val = x[row, col] * if vars[col] == -1: # <<<<<<<<<<<<<< @@ -5905,7 +5971,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":275 + /* "Orange/distance/_distance.pyx":277 * val = x[row, col] * if vars[col] == -1: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5915,7 +5981,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":276 + /* "Orange/distance/_distance.pyx":278 * if vars[col] == -1: * if npy_isnan(val): * d += means[col] # <<<<<<<<<<<<<< @@ -5925,7 +5991,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_18 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":275 + /* "Orange/distance/_distance.pyx":277 * val = x[row, col] * if vars[col] == -1: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5935,7 +6001,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":279 * if npy_isnan(val): * d += means[col] * elif val != 0: # <<<<<<<<<<<<<< @@ -5945,7 +6011,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":280 * d += means[col] * elif val != 0: * d += 1 # <<<<<<<<<<<<<< @@ -5954,7 +6020,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":279 * if npy_isnan(val): * d += means[col] * elif val != 0: # <<<<<<<<<<<<<< @@ -5964,7 +6030,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } __pyx_L12:; - /* "Orange/distance/_distance.pyx":274 + /* "Orange/distance/_distance.pyx":276 * continue * val = x[row, col] * if vars[col] == -1: # <<<<<<<<<<<<<< @@ -5974,7 +6040,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":280 + /* "Orange/distance/_distance.pyx":282 * d += 1 * else: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -5985,7 +6051,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":281 + /* "Orange/distance/_distance.pyx":283 * else: * if npy_isnan(val): * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -5996,7 +6062,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_t_20 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":280 + /* "Orange/distance/_distance.pyx":282 * d += 1 * else: * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -6006,7 +6072,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":283 + /* "Orange/distance/_distance.pyx":285 * d += means[col] ** 2 + vars[col] * else: * d += val ** 2 # <<<<<<<<<<<<<< @@ -6022,7 +6088,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli __pyx_L8_continue:; } - /* "Orange/distance/_distance.pyx":284 + /* "Orange/distance/_distance.pyx":286 * else: * d += val ** 2 * abss[row] = sqrt(d) # <<<<<<<<<<<<<< @@ -6034,7 +6100,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":267 + /* "Orange/distance/_distance.pyx":269 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_rows) * with nogil: # <<<<<<<<<<<<<< @@ -6052,7 +6118,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":285 + /* "Orange/distance/_distance.pyx":287 * d += val ** 2 * abss[row] = sqrt(d) * return abss # <<<<<<<<<<<<<< @@ -6060,13 +6126,13 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":259 + /* "Orange/distance/_distance.pyx":261 * * * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -6091,7 +6157,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewsli return __pyx_r; } -/* "Orange/distance/_distance.pyx":288 +/* "Orange/distance/_distance.pyx":290 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -6133,21 +6199,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *_ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 290, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 290, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 290, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 290, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6159,19 +6225,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *_ } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 292, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 290, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 288, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 289, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 290, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 291, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -6252,64 +6318,64 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 288, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 290, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 288, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 290, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":293 + /* "Orange/distance/_distance.pyx":295 * fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 293, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":294 + /* "Orange/distance/_distance.pyx":296 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * double [:] dist_missing2 = fit_params["dist_missing2"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 294, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":295 + /* "Orange/distance/_distance.pyx":297 * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":302 + /* "Orange/distance/_distance.pyx":304 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -6321,7 +6387,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":303 + /* "Orange/distance/_distance.pyx":305 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -6330,7 +6396,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":304 + /* "Orange/distance/_distance.pyx":306 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -6341,36 +6407,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":305 + /* "Orange/distance/_distance.pyx":307 * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing2) # <<<<<<<<<<<<<< * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); } } } - /* "Orange/distance/_distance.pyx":304 + /* "Orange/distance/_distance.pyx":306 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< @@ -6379,12 +6445,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 304, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":306 + /* "Orange/distance/_distance.pyx":308 * assert n_cols == x2.shape[1] == len(vars) == len(means) \ * == len(dist_missing2) * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< @@ -6392,18 +6458,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 306, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 306, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_abs1 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":307 + /* "Orange/distance/_distance.pyx":309 * == len(dist_missing2) * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< @@ -6412,21 +6478,21 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if ((__pyx_v_two_tables != 0)) { __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 307, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 309, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL; } else { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 307, __pyx_L1_error) + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 309, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_10; __pyx_t_10.memview = NULL; @@ -6436,23 +6502,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":308 + /* "Orange/distance/_distance.pyx":310 * abs1 = _abs_rows(x1, means, vars) * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * * with nogil: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); @@ -6460,27 +6526,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); __pyx_t_1 = 0; __pyx_t_12 = 0; - __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = 0; - __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 310, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":310 + /* "Orange/distance/_distance.pyx":312 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -6494,7 +6560,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":311 + /* "Orange/distance/_distance.pyx":313 * * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -6505,7 +6571,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row1 = __pyx_t_15; - /* "Orange/distance/_distance.pyx":312 + /* "Orange/distance/_distance.pyx":314 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -6520,7 +6586,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_row2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":313 + /* "Orange/distance/_distance.pyx":315 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< @@ -6529,7 +6595,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":316 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -6540,7 +6606,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_col = __pyx_t_19; - /* "Orange/distance/_distance.pyx":315 + /* "Orange/distance/_distance.pyx":317 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -6551,7 +6617,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":316 + /* "Orange/distance/_distance.pyx":318 * for col in range(n_cols): * if vars[col] == -2: * continue # <<<<<<<<<<<<<< @@ -6560,7 +6626,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":315 + /* "Orange/distance/_distance.pyx":317 * d = 0 * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -6569,7 +6635,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":317 + /* "Orange/distance/_distance.pyx":319 * if vars[col] == -2: * continue * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -6585,7 +6651,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_v_val1 = __pyx_t_23; __pyx_v_val2 = __pyx_t_26; - /* "Orange/distance/_distance.pyx":318 + /* "Orange/distance/_distance.pyx":320 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6603,7 +6669,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L14_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":321 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -6613,7 +6679,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_28 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":318 + /* "Orange/distance/_distance.pyx":320 * continue * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6623,7 +6689,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":320 + /* "Orange/distance/_distance.pyx":322 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -6634,7 +6700,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":321 + /* "Orange/distance/_distance.pyx":323 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6654,7 +6720,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } __pyx_L18_next_or:; - /* "Orange/distance/_distance.pyx":322 + /* "Orange/distance/_distance.pyx":324 * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< @@ -6671,7 +6737,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = __pyx_t_27; __pyx_L17_bool_binop_done:; - /* "Orange/distance/_distance.pyx":321 + /* "Orange/distance/_distance.pyx":323 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6680,7 +6746,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":323 + /* "Orange/distance/_distance.pyx":325 * if npy_isnan(val1) and val2 != 0 \ * or npy_isnan(val2) and val1 != 0: * d += means[col] # <<<<<<<<<<<<<< @@ -6690,7 +6756,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_30 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":321 + /* "Orange/distance/_distance.pyx":323 * d += dist_missing2[col] * elif vars[col] == -1: * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< @@ -6700,7 +6766,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":324 + /* "Orange/distance/_distance.pyx":326 * or npy_isnan(val2) and val1 != 0: * d += means[col] * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -6718,7 +6784,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L21_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":325 + /* "Orange/distance/_distance.pyx":327 * d += means[col] * elif val1 != 0 and val2 != 0: * d += 1 # <<<<<<<<<<<<<< @@ -6727,7 +6793,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":324 + /* "Orange/distance/_distance.pyx":326 * or npy_isnan(val2) and val1 != 0: * d += means[col] * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -6737,7 +6803,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } __pyx_L16:; - /* "Orange/distance/_distance.pyx":320 + /* "Orange/distance/_distance.pyx":322 * if npy_isnan(val1) and npy_isnan(val2): * d += dist_missing2[col] * elif vars[col] == -1: # <<<<<<<<<<<<<< @@ -6747,7 +6813,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":327 + /* "Orange/distance/_distance.pyx":329 * d += 1 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6758,7 +6824,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":328 + /* "Orange/distance/_distance.pyx":330 * else: * if npy_isnan(val1): * d += val2 * means[col] # <<<<<<<<<<<<<< @@ -6768,7 +6834,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_31 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":327 + /* "Orange/distance/_distance.pyx":329 * d += 1 * else: * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6778,7 +6844,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":331 * if npy_isnan(val1): * d += val2 * means[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6788,7 +6854,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":330 + /* "Orange/distance/_distance.pyx":332 * d += val2 * means[col] * elif npy_isnan(val2): * d += val1 * means[col] # <<<<<<<<<<<<<< @@ -6798,7 +6864,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_32 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":331 * if npy_isnan(val1): * d += val2 * means[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6808,7 +6874,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":332 + /* "Orange/distance/_distance.pyx":334 * d += val1 * means[col] * else: * d += val1 * val2 # <<<<<<<<<<<<<< @@ -6824,7 +6890,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_L10_continue:; } - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":335 * else: * d += val1 * val2 * d = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< @@ -6835,7 +6901,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_34 = __pyx_v_row2; __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":334 + /* "Orange/distance/_distance.pyx":336 * d += val1 * val2 * d = 1 - d / abs1[row1] / abs2[row2] * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< @@ -6845,7 +6911,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = ((__pyx_v_d < 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":335 + /* "Orange/distance/_distance.pyx":337 * d = 1 - d / abs1[row1] / abs2[row2] * if d < 0: # clip off any numeric errors * d = 0 # <<<<<<<<<<<<<< @@ -6854,7 +6920,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":334 + /* "Orange/distance/_distance.pyx":336 * d += val1 * val2 * d = 1 - d / abs1[row1] / abs2[row2] * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< @@ -6864,7 +6930,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS goto __pyx_L24; } - /* "Orange/distance/_distance.pyx":336 + /* "Orange/distance/_distance.pyx":338 * if d < 0: # clip off any numeric errors * d = 0 * elif d > 1: # <<<<<<<<<<<<<< @@ -6874,7 +6940,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = ((__pyx_v_d > 1.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":337 + /* "Orange/distance/_distance.pyx":339 * d = 0 * elif d > 1: * d = 1 # <<<<<<<<<<<<<< @@ -6883,7 +6949,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_v_d = 1.0; - /* "Orange/distance/_distance.pyx":336 + /* "Orange/distance/_distance.pyx":338 * if d < 0: # clip off any numeric errors * d = 0 * elif d > 1: # <<<<<<<<<<<<<< @@ -6893,7 +6959,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } __pyx_L24:; - /* "Orange/distance/_distance.pyx":338 + /* "Orange/distance/_distance.pyx":340 * elif d > 1: * d = 1 * distances[row1, row2] = d # <<<<<<<<<<<<<< @@ -6907,7 +6973,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":310 + /* "Orange/distance/_distance.pyx":312 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * * with nogil: # <<<<<<<<<<<<<< @@ -6925,7 +6991,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":341 * d = 1 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -6935,7 +7001,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":342 * distances[row1, row2] = d * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -6944,7 +7010,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":341 * d = 1 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -6953,7 +7019,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":341 + /* "Orange/distance/_distance.pyx":343 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -6961,13 +7027,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":288 + /* "Orange/distance/_distance.pyx":290 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -7009,7 +7075,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":344 +/* "Orange/distance/_distance.pyx":346 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -7050,7 +7116,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli Py_ssize_t __pyx_t_20; __Pyx_RefNannySetupContext("_abs_cols", 0); - /* "Orange/distance/_distance.pyx":350 + /* "Orange/distance/_distance.pyx":352 * int row, col, n_rows, n_cols, nan_cont * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -7062,19 +7128,19 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":351 + /* "Orange/distance/_distance.pyx":353 * * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) # <<<<<<<<<<<<<< * with nogil: * for col in range(n_cols): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { @@ -7087,29 +7153,29 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 351, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":352 + /* "Orange/distance/_distance.pyx":354 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7123,7 +7189,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":353 + /* "Orange/distance/_distance.pyx":355 * abss = np.empty(n_cols) * with nogil: * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -7134,7 +7200,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_col = __pyx_t_10; - /* "Orange/distance/_distance.pyx":354 + /* "Orange/distance/_distance.pyx":356 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -7145,7 +7211,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":355 + /* "Orange/distance/_distance.pyx":357 * for col in range(n_cols): * if vars[col] == -2: * abss[col] = 1 # <<<<<<<<<<<<<< @@ -7155,7 +7221,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_13 = __pyx_v_col; *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; - /* "Orange/distance/_distance.pyx":356 + /* "Orange/distance/_distance.pyx":358 * if vars[col] == -2: * abss[col] = 1 * continue # <<<<<<<<<<<<<< @@ -7164,7 +7230,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ goto __pyx_L6_continue; - /* "Orange/distance/_distance.pyx":354 + /* "Orange/distance/_distance.pyx":356 * with nogil: * for col in range(n_cols): * if vars[col] == -2: # <<<<<<<<<<<<<< @@ -7173,7 +7239,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ } - /* "Orange/distance/_distance.pyx":357 + /* "Orange/distance/_distance.pyx":359 * abss[col] = 1 * continue * d = 0 # <<<<<<<<<<<<<< @@ -7182,7 +7248,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":358 + /* "Orange/distance/_distance.pyx":360 * continue * d = 0 * nan_cont = 0 # <<<<<<<<<<<<<< @@ -7191,7 +7257,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_nan_cont = 0; - /* "Orange/distance/_distance.pyx":359 + /* "Orange/distance/_distance.pyx":361 * d = 0 * nan_cont = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7202,7 +7268,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":360 + /* "Orange/distance/_distance.pyx":362 * nan_cont = 0 * for row in range(n_rows): * val = x[row, col] # <<<<<<<<<<<<<< @@ -7213,7 +7279,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_17 = __pyx_v_col; __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":361 + /* "Orange/distance/_distance.pyx":363 * for row in range(n_rows): * val = x[row, col] * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -7223,7 +7289,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":362 + /* "Orange/distance/_distance.pyx":364 * val = x[row, col] * if npy_isnan(val): * nan_cont += 1 # <<<<<<<<<<<<<< @@ -7232,7 +7298,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli */ __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); - /* "Orange/distance/_distance.pyx":361 + /* "Orange/distance/_distance.pyx":363 * for row in range(n_rows): * val = x[row, col] * if npy_isnan(val): # <<<<<<<<<<<<<< @@ -7242,7 +7308,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli goto __pyx_L11; } - /* "Orange/distance/_distance.pyx":364 + /* "Orange/distance/_distance.pyx":366 * nan_cont += 1 * else: * d += val ** 2 # <<<<<<<<<<<<<< @@ -7255,7 +7321,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_L11:; } - /* "Orange/distance/_distance.pyx":365 + /* "Orange/distance/_distance.pyx":367 * else: * d += val ** 2 * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< @@ -7266,7 +7332,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __pyx_t_19 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":366 + /* "Orange/distance/_distance.pyx":368 * d += val ** 2 * d += nan_cont * (means[col] ** 2 + vars[col]) * abss[col] = sqrt(d) # <<<<<<<<<<<<<< @@ -7279,7 +7345,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":352 + /* "Orange/distance/_distance.pyx":354 * n_rows, n_cols = x.shape[0], x.shape[1] * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< @@ -7297,7 +7363,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":367 + /* "Orange/distance/_distance.pyx":369 * d += nan_cont * (means[col] ** 2 + vars[col]) * abss[col] = sqrt(d) * return abss # <<<<<<<<<<<<<< @@ -7305,13 +7371,13 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":344 + /* "Orange/distance/_distance.pyx":346 * * * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< @@ -7336,7 +7402,7 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli return __pyx_r; } -/* "Orange/distance/_distance.pyx":370 +/* "Orange/distance/_distance.pyx":372 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -7374,11 +7440,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *_ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 370, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 372, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 370, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 372, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -7391,13 +7457,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 370, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 372, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 370, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 372, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -7479,43 +7545,43 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 370, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 372, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":372 + /* "Orange/distance/_distance.pyx":374 * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< * double [:] means = fit_params["means"] * */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 372, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vars = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":373 + /* "Orange/distance/_distance.pyx":375 * cdef: * double [:] vars = fit_params["vars"] * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, row, col1, col2 */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 373, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_means = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":384 * np.ndarray[np.float64_t, ndim=2] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -7527,7 +7593,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":383 + /* "Orange/distance/_distance.pyx":385 * * n_rows, n_cols = x.shape[0], x.shape[1] * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< @@ -7536,26 +7602,26 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); if (__pyx_t_6) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); } if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 383, __pyx_L1_error) + __PYX_ERR(0, 385, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":384 + /* "Orange/distance/_distance.pyx":386 * n_rows, n_cols = x.shape[0], x.shape[1] * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< @@ -7563,34 +7629,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS * for col1 in range(n_cols): */ __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 384, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 386, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_abss = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":387 * assert n_cols == len(vars) == len(means) * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * for col1 in range(n_cols): * if vars[col1] == -2: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); @@ -7598,20 +7664,20 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __pyx_t_1 = 0; __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 385, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 387, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 385, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 387, __pyx_L1_error) __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7627,13 +7693,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS } } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 385, __pyx_L1_error) + if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 387, __pyx_L1_error) } __pyx_t_12 = 0; __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":386 + /* "Orange/distance/_distance.pyx":388 * abss = _abs_cols(x, means, vars) * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -7644,7 +7710,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { __pyx_v_col1 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":389 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< @@ -7655,16 +7721,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":388 + /* "Orange/distance/_distance.pyx":390 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); @@ -7672,11 +7738,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_slice__2); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice__2); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 388, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -7684,10 +7750,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __pyx_t_11 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 388, __pyx_L1_error) + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":389 + /* "Orange/distance/_distance.pyx":391 * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 * continue # <<<<<<<<<<<<<< @@ -7696,7 +7762,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L3_continue; - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":389 * distances = np.zeros((n_cols, n_cols), dtype=float) * for col1 in range(n_cols): * if vars[col1] == -2: # <<<<<<<<<<<<<< @@ -7705,7 +7771,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":390 + /* "Orange/distance/_distance.pyx":392 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -7719,7 +7785,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":391 + /* "Orange/distance/_distance.pyx":393 * continue * with nogil: * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -7730,7 +7796,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_col2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":394 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7741,7 +7807,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":395 * for col2 in range(col1): * if vars[col2] == -2: * continue # <<<<<<<<<<<<<< @@ -7750,7 +7816,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ goto __pyx_L11_continue; - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":394 * with nogil: * for col2 in range(col1): * if vars[col2] == -2: # <<<<<<<<<<<<<< @@ -7759,7 +7825,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ } - /* "Orange/distance/_distance.pyx":394 + /* "Orange/distance/_distance.pyx":396 * if vars[col2] == -2: * continue * d = 0 # <<<<<<<<<<<<<< @@ -7768,7 +7834,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":395 + /* "Orange/distance/_distance.pyx":397 * continue * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7779,7 +7845,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_row = __pyx_t_23; - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":398 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -7795,7 +7861,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_v_val1 = __pyx_t_26; __pyx_v_val2 = __pyx_t_29; - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":399 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7813,7 +7879,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L17_bool_binop_done:; if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":398 + /* "Orange/distance/_distance.pyx":400 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] # <<<<<<<<<<<<<< @@ -7824,7 +7890,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_32 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":399 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7834,7 +7900,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":399 + /* "Orange/distance/_distance.pyx":401 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7844,7 +7910,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":400 + /* "Orange/distance/_distance.pyx":402 * d += means[col1] * means[col2] * elif npy_isnan(val1): * d += val2 * means[col1] # <<<<<<<<<<<<<< @@ -7854,7 +7920,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_33 = __pyx_v_col1; __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":399 + /* "Orange/distance/_distance.pyx":401 * if npy_isnan(val1) and npy_isnan(val2): * d += means[col1] * means[col2] * elif npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7864,7 +7930,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":401 + /* "Orange/distance/_distance.pyx":403 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7874,7 +7940,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":402 + /* "Orange/distance/_distance.pyx":404 * d += val2 * means[col1] * elif npy_isnan(val2): * d += val1 * means[col2] # <<<<<<<<<<<<<< @@ -7884,7 +7950,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_34 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":401 + /* "Orange/distance/_distance.pyx":403 * elif npy_isnan(val1): * d += val2 * means[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7894,7 +7960,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":404 + /* "Orange/distance/_distance.pyx":406 * d += val1 * means[col2] * else: * d += val1 * val2 # <<<<<<<<<<<<<< @@ -7907,7 +7973,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L16:; } - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":408 * d += val1 * val2 * * d = 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< @@ -7918,7 +7984,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_36 = __pyx_v_col2; __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":407 + /* "Orange/distance/_distance.pyx":409 * * d = 1 - d / abss[col1] / abss[col2] * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< @@ -7928,7 +7994,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = ((__pyx_v_d < 0.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":408 + /* "Orange/distance/_distance.pyx":410 * d = 1 - d / abss[col1] / abss[col2] * if d < 0: # clip off any numeric errors * d = 0 # <<<<<<<<<<<<<< @@ -7937,7 +8003,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":407 + /* "Orange/distance/_distance.pyx":409 * * d = 1 - d / abss[col1] / abss[col2] * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< @@ -7947,7 +8013,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS goto __pyx_L19; } - /* "Orange/distance/_distance.pyx":409 + /* "Orange/distance/_distance.pyx":411 * if d < 0: # clip off any numeric errors * d = 0 * elif d > 1: # <<<<<<<<<<<<<< @@ -7957,7 +8023,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_t_6 = ((__pyx_v_d > 1.0) != 0); if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":410 + /* "Orange/distance/_distance.pyx":412 * d = 0 * elif d > 1: * d = 1 # <<<<<<<<<<<<<< @@ -7966,7 +8032,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS */ __pyx_v_d = 1.0; - /* "Orange/distance/_distance.pyx":409 + /* "Orange/distance/_distance.pyx":411 * if d < 0: # clip off any numeric errors * d = 0 * elif d > 1: # <<<<<<<<<<<<<< @@ -7976,7 +8042,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS } __pyx_L19:; - /* "Orange/distance/_distance.pyx":411 + /* "Orange/distance/_distance.pyx":413 * elif d > 1: * d = 1 * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -7993,7 +8059,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":390 + /* "Orange/distance/_distance.pyx":392 * distances[col1, :] = distances[:, col1] = 1.0 * continue * with nogil: # <<<<<<<<<<<<<< @@ -8013,7 +8079,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_L3_continue:; } - /* "Orange/distance/_distance.pyx":412 + /* "Orange/distance/_distance.pyx":414 * d = 1 * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< @@ -8025,7 +8091,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":370 + /* "Orange/distance/_distance.pyx":372 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -8064,7 +8130,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":415 +/* "Orange/distance/_distance.pyx":417 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -8106,21 +8172,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 415, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 417, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 415, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 417, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 415, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 417, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 415, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 417, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -8132,19 +8198,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 419, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 415, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 417, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 415, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 416, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 417, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 418, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ @@ -8216,32 +8282,32 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 415, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 417, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 415, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 417, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":420 + /* "Orange/distance/_distance.pyx":422 * fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 420, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":427 + /* "Orange/distance/_distance.pyx":429 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -8253,7 +8319,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":428 + /* "Orange/distance/_distance.pyx":430 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -8262,7 +8328,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":431 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< @@ -8277,28 +8343,28 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 429, __pyx_L1_error) + __PYX_ERR(0, 431, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":431 + /* "Orange/distance/_distance.pyx":433 * assert n_cols == x2.shape[1] == ps.shape[0] * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -8306,27 +8372,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 431, __pyx_L1_error) + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 431, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 433, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 431, __pyx_L1_error) + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":432 + /* "Orange/distance/_distance.pyx":434 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8340,7 +8406,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":433 + /* "Orange/distance/_distance.pyx":435 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -8351,7 +8417,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_row1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":434 + /* "Orange/distance/_distance.pyx":436 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -8366,7 +8432,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":435 + /* "Orange/distance/_distance.pyx":437 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 # <<<<<<<<<<<<<< @@ -8376,7 +8442,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_intersection = 0.0; __pyx_v_union = 0.0; - /* "Orange/distance/_distance.pyx":436 + /* "Orange/distance/_distance.pyx":438 * for row2 in range(n_rows2 if two_tables else row1): * intersection = union = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -8387,7 +8453,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":439 * intersection = union = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -8403,7 +8469,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":440 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8413,7 +8479,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":441 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8423,7 +8489,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":442 * if npy_isnan(val1): * if npy_isnan(val2): * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< @@ -8433,7 +8499,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_22 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); - /* "Orange/distance/_distance.pyx":441 + /* "Orange/distance/_distance.pyx":443 * if npy_isnan(val2): * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< @@ -8443,7 +8509,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_23 = __pyx_v_col; __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":441 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8453,7 +8519,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":442 + /* "Orange/distance/_distance.pyx":444 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8463,7 +8529,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":443 + /* "Orange/distance/_distance.pyx":445 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8473,7 +8539,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_24 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":444 + /* "Orange/distance/_distance.pyx":446 * elif val2 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8482,7 +8548,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":442 + /* "Orange/distance/_distance.pyx":444 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8492,7 +8558,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":448 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8505,7 +8571,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L13:; - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":440 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8515,7 +8581,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":449 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8525,7 +8591,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":450 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8535,7 +8601,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":451 * elif npy_isnan(val2): * if val1 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8545,7 +8611,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_26 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); - /* "Orange/distance/_distance.pyx":450 + /* "Orange/distance/_distance.pyx":452 * if val1 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -8554,7 +8620,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":450 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8564,7 +8630,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":452 + /* "Orange/distance/_distance.pyx":454 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -8577,7 +8643,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } __pyx_L14:; - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":449 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8587,7 +8653,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":454 + /* "Orange/distance/_distance.pyx":456 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8606,7 +8672,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L16_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":455 + /* "Orange/distance/_distance.pyx":457 * else: * if val1 != 0 and val2 != 0: * intersection += 1 # <<<<<<<<<<<<<< @@ -8615,7 +8681,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":454 + /* "Orange/distance/_distance.pyx":456 * union += ps[col] * else: * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< @@ -8624,7 +8690,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":456 + /* "Orange/distance/_distance.pyx":458 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8642,7 +8708,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L19_bool_binop_done:; if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":459 * intersection += 1 * if val1 != 0 or val2 != 0: * union += 1 # <<<<<<<<<<<<<< @@ -8651,7 +8717,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":456 + /* "Orange/distance/_distance.pyx":458 * if val1 != 0 and val2 != 0: * intersection += 1 * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< @@ -8663,7 +8729,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_L12:; } - /* "Orange/distance/_distance.pyx":458 + /* "Orange/distance/_distance.pyx":460 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8673,7 +8739,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":459 + /* "Orange/distance/_distance.pyx":461 * union += 1 * if union != 0: * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< @@ -8684,7 +8750,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_30 = __pyx_v_row2; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":458 + /* "Orange/distance/_distance.pyx":460 * if val1 != 0 or val2 != 0: * union += 1 * if union != 0: # <<<<<<<<<<<<<< @@ -8696,7 +8762,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":432 + /* "Orange/distance/_distance.pyx":434 * * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8714,7 +8780,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":461 + /* "Orange/distance/_distance.pyx":463 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8724,7 +8790,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":462 + /* "Orange/distance/_distance.pyx":464 * * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< @@ -8733,7 +8799,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":461 + /* "Orange/distance/_distance.pyx":463 * distances[row1, row2] = 1 - intersection / union * * if not two_tables: # <<<<<<<<<<<<<< @@ -8742,7 +8808,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ } - /* "Orange/distance/_distance.pyx":463 + /* "Orange/distance/_distance.pyx":465 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -8750,13 +8816,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":415 + /* "Orange/distance/_distance.pyx":417 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -8793,7 +8859,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":466 +/* "Orange/distance/_distance.pyx":468 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -8831,11 +8897,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 466, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 468, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 466, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 468, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -8848,13 +8914,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 466, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 468, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 466, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 468, __pyx_L1_error) __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ @@ -8929,55 +8995,55 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 466, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 468, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":468 + /* "Orange/distance/_distance.pyx":470 * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): * cdef: * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * * int n_rows, n_cols, col1, col2, row */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 468, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ps = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":475 + /* "Orange/distance/_distance.pyx":477 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): + * with nogil: */ __pyx_t_3 = (__pyx_v_x->dimensions[0]); __pyx_t_4 = (__pyx_v_x->dimensions[1]); __pyx_v_n_rows = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":478 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * with nogil: + * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); @@ -8985,420 +9051,453 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 476, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 478, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 476, __pyx_L1_error) + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":477 + /* "Orange/distance/_distance.pyx":479 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * in_both = in_one = 0 + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ - __pyx_t_9 = __pyx_v_n_cols; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_col1 = __pyx_t_10; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":478 + /* "Orange/distance/_distance.pyx":480 * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * with nogil: + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * in_both = in_one = 0 */ - __pyx_t_11 = __pyx_v_col1; - for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { - __pyx_v_col2 = __pyx_t_12; + __pyx_t_9 = __pyx_v_n_cols; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_col1 = __pyx_t_10; - /* "Orange/distance/_distance.pyx":479 - * for col1 in range(n_cols): - * for col2 in range(col1): - * in_both = in_one = 0 # <<<<<<<<<<<<<< - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): + /* "Orange/distance/_distance.pyx":481 + * with nogil: + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 */ - __pyx_v_in_both = 0; - __pyx_v_in_one = 0; + __pyx_t_11 = __pyx_v_col1; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_col2 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":480 - * for col2 in range(col1): - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":482 + * for col1 in range(n_cols): + * for col2 in range(col1): + * in_both = in_one = 0 # <<<<<<<<<<<<<< + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): */ - __pyx_v_in1_unk2 = 0; - __pyx_v_unk1_in2 = 0; - __pyx_v_unk1_unk2 = 0; - __pyx_v_unk1_not2 = 0; - __pyx_v_not1_unk2 = 0; + __pyx_v_in_both = 0; + __pyx_v_in_one = 0; - /* "Orange/distance/_distance.pyx":481 - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":483 + * for col2 in range(col1): + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_t_13 = __pyx_v_n_rows; - for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { - __pyx_v_row = __pyx_t_14; + __pyx_v_in1_unk2 = 0; + __pyx_v_unk1_in2 = 0; + __pyx_v_unk1_unk2 = 0; + __pyx_v_unk1_not2 = 0; + __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":482 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): - */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col1; - __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_18 = __pyx_v_row; - __pyx_t_19 = __pyx_v_col2; - __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_17; - __pyx_v_val2 = __pyx_t_20; - - /* "Orange/distance/_distance.pyx":483 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 + /* "Orange/distance/_distance.pyx":484 + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): */ - __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_21) { + __pyx_t_13 = __pyx_v_n_rows; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_v_row = __pyx_t_14; - /* "Orange/distance/_distance.pyx":484 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":485 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col1; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_18 = __pyx_v_row; + __pyx_t_19 = __pyx_v_col2; + __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_17; + __pyx_v_val2 = __pyx_t_20; - /* "Orange/distance/_distance.pyx":485 - * if npy_isnan(val1): - * if npy_isnan(val2): - * unk1_unk2 += 1 # <<<<<<<<<<<<<< - * elif val2 != 0: - * unk1_in2 += 1 + /* "Orange/distance/_distance.pyx":486 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ - __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); + __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":484 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":487 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: */ - goto __pyx_L10; - } + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":486 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 - * else: + /* "Orange/distance/_distance.pyx":488 + * if npy_isnan(val1): + * if npy_isnan(val2): + * unk1_unk2 += 1 # <<<<<<<<<<<<<< + * elif val2 != 0: + * unk1_in2 += 1 */ - __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_21) { + __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":487 - * unk1_unk2 += 1 - * elif val2 != 0: - * unk1_in2 += 1 # <<<<<<<<<<<<<< - * else: - * unk1_not2 += 1 + /* "Orange/distance/_distance.pyx":487 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: */ - __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":486 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 - * else: + /* "Orange/distance/_distance.pyx":489 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: */ - goto __pyx_L10; - } + __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":489 - * unk1_in2 += 1 - * else: - * unk1_not2 += 1 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: + /* "Orange/distance/_distance.pyx":490 + * unk1_unk2 += 1 + * elif val2 != 0: + * unk1_in2 += 1 # <<<<<<<<<<<<<< + * else: + * unk1_not2 += 1 */ - /*else*/ { - __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); - } - __pyx_L10:; + __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "Orange/distance/_distance.pyx":483 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 + /* "Orange/distance/_distance.pyx":489 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: */ - goto __pyx_L9; - } + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":490 - * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 - */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":491 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: + /* "Orange/distance/_distance.pyx":492 + * unk1_in2 += 1 + * else: + * unk1_not2 += 1 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: */ - __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_21) { + /*else*/ { + __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); + } + __pyx_L13:; - /* "Orange/distance/_distance.pyx":492 - * elif npy_isnan(val2): - * if val1 != 0: - * in1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * not1_unk2 += 1 + /* "Orange/distance/_distance.pyx":486 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ - __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":491 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: + /* "Orange/distance/_distance.pyx":493 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 */ - goto __pyx_L11; - } + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":494 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_21) { + + /* "Orange/distance/_distance.pyx":495 + * elif npy_isnan(val2): + * if val1 != 0: + * in1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * not1_unk2 += 1 + */ + __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + + /* "Orange/distance/_distance.pyx":494 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":494 - * in1_unk2 += 1 + /* "Orange/distance/_distance.pyx":497 + * in1_unk2 += 1 + * else: + * not1_unk2 += 1 # <<<<<<<<<<<<<< * else: - * not1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * if val1 != 0 and val2 != 0: + * if val1 != 0 and val2 != 0: */ - /*else*/ { - __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); - } - __pyx_L11:; + /*else*/ { + __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":493 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 + */ + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":490 + /* "Orange/distance/_distance.pyx":499 + * not1_unk2 += 1 * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: */ - goto __pyx_L9; - } + /*else*/ { + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L16_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L16_bool_binop_done:; + if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":496 - * not1_unk2 += 1 - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: + /* "Orange/distance/_distance.pyx":500 + * else: + * if val1 != 0 and val2 != 0: + * in_both += 1 # <<<<<<<<<<<<<< + * elif val1 != 0 or val2 != 0: + * in_one += 1 */ - /*else*/ { - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L13_bool_binop_done; - } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L13_bool_binop_done:; - if (__pyx_t_21) { + __pyx_v_in_both = (__pyx_v_in_both + 1); - /* "Orange/distance/_distance.pyx":497 - * else: - * if val1 != 0 and val2 != 0: - * in_both += 1 # <<<<<<<<<<<<<< - * elif val1 != 0 or val2 != 0: - * in_one += 1 + /* "Orange/distance/_distance.pyx":499 + * not1_unk2 += 1 + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: */ - __pyx_v_in_both = (__pyx_v_in_both + 1); + goto __pyx_L15; + } - /* "Orange/distance/_distance.pyx":496 - * not1_unk2 += 1 - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: + /* "Orange/distance/_distance.pyx":501 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ */ - goto __pyx_L12; - } + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L18_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L18_bool_binop_done:; + if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":498 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ + /* "Orange/distance/_distance.pyx":502 + * in_both += 1 + * elif val1 != 0 or val2 != 0: + * in_one += 1 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both */ - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L15_bool_binop_done; - } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L15_bool_binop_done:; - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":499 - * in_both += 1 - * elif val1 != 0 or val2 != 0: - * in_one += 1 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - */ - __pyx_v_in_one = (__pyx_v_in_one + 1); - - /* "Orange/distance/_distance.pyx":498 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ + __pyx_v_in_one = (__pyx_v_in_one + 1); + + /* "Orange/distance/_distance.pyx":501 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ */ - } - __pyx_L12:; - } - __pyx_L9:; - } + } + __pyx_L15:; + } + __pyx_L12:; + } - /* "Orange/distance/_distance.pyx":502 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ - */ - __pyx_t_23 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":503 - * 1 - float(in_both - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - */ - __pyx_t_24 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":504 - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - */ - __pyx_t_25 = __pyx_v_col1; - __pyx_t_26 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":506 - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - */ - __pyx_t_27 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":507 - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + /* "Orange/distance/_distance.pyx":505 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ + */ + __pyx_t_23 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":506 + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + + */ + __pyx_t_24 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":507 + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + */ + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":509 + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + */ + __pyx_t_27 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":510 + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * return distances */ - __pyx_t_28 = __pyx_v_col2; + __pyx_t_28 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":508 - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":511 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< * return distances */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":501 - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both # <<<<<<<<<<<<<< - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + + /* "Orange/distance/_distance.pyx":504 + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both # <<<<<<<<<<<<<< + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + */ - __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); + __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - /* "Orange/distance/_distance.pyx":500 - * elif val1 != 0 or val2 != 0: - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< - * 1 - float(in_both - * + ps[col1] * unk1_in2 + + /* "Orange/distance/_distance.pyx":503 + * elif val1 != 0 or val2 != 0: + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - float(in_both + * + ps[col1] * unk1_in2 + */ - __pyx_t_32 = __pyx_v_col1; - __pyx_t_33 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; - __pyx_t_34 = __pyx_v_col2; - __pyx_t_35 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; - } + __pyx_t_32 = __pyx_v_col1; + __pyx_t_33 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + __pyx_t_34 = __pyx_v_col2; + __pyx_t_35 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + } + } + } + + /* "Orange/distance/_distance.pyx":479 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } } - /* "Orange/distance/_distance.pyx":509 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + /* "Orange/distance/_distance.pyx":512 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":468 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< @@ -23980,17 +24079,17 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "Orange/distance/_distance.pyx":388 + /* "Orange/distance/_distance.pyx":390 * for col1 in range(n_cols): * if vars[col1] == -2: * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< * continue * with nogil: */ - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); - __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); @@ -24242,77 +24341,77 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__27); __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 138, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 201, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":246 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31); - __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 244, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 246, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":288 + /* "Orange/distance/_distance.pyx":290 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33); - __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 288, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 290, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 290, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":370 + /* "Orange/distance/_distance.pyx":372 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] vars = fit_params["vars"] */ - __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 372, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 372, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":415 + /* "Orange/distance/_distance.pyx":417 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 415, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 415, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 415, __pyx_L1_error) + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 417, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 417, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":468 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39); - __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 466, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 468, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 468, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -24574,76 +24673,76 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":201 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] medians = fit_params["medians"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 200, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 201, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":244 + /* "Orange/distance/_distance.pyx":246 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 244, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":288 + /* "Orange/distance/_distance.pyx":290 * * * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 288, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":370 + /* "Orange/distance/_distance.pyx":372 * * * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] vars = fit_params["vars"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 370, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":415 + /* "Orange/distance/_distance.pyx":417 * * * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 415, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":468 * * * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< * cdef: * double [:] ps = fit_params["ps"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 466, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index 0e7226c0b11..db48a3b1d47 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -157,40 +157,41 @@ def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, == len(dist_missing) == len(dist_missing2) distances = np.zeros((n_rows1, n_rows2), dtype=float) - for row1 in range(n_rows1): - for row2 in range(n_rows2 if two_tables else row1): - d = 0 - for col in range(n_cols): - if mads[col] == -2: - continue + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + d = 0 + for col in range(n_cols): + if mads[col] == -2: + continue - val1, val2 = x1[row1, col], x2[row2, col] - if npy_isnan(val1) and npy_isnan(val2): - d += dist_missing2[col] - elif mads[col] == -1: - ival1, ival2 = int(val1), int(val2) - if npy_isnan(val1): - d += dist_missing[col, ival2] - elif npy_isnan(val2): - d += dist_missing[col, ival1] - elif ival1 != ival2: - d += 1 - elif normalize: - if npy_isnan(val1): - d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - elif npy_isnan(val2): - d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - else: - d += fabs(val1 - val2) / mads[col] / 2 - else: - if npy_isnan(val1): - d += fabs(val2 - medians[col]) + mads[col] - elif npy_isnan(val2): - d += fabs(val1 - medians[col]) + mads[col] + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1) and npy_isnan(val2): + d += dist_missing2[col] + elif mads[col] == -1: + ival1, ival2 = int(val1), int(val2) + if npy_isnan(val1): + d += dist_missing[col, ival2] + elif npy_isnan(val2): + d += dist_missing[col, ival1] + elif ival1 != ival2: + d += 1 + elif normalize: + if npy_isnan(val1): + d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + elif npy_isnan(val2): + d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + else: + d += fabs(val1 - val2) / mads[col] / 2 else: - d += fabs(val1 - val2) + if npy_isnan(val1): + d += fabs(val2 - medians[col]) + mads[col] + elif npy_isnan(val2): + d += fabs(val1 - medians[col]) + mads[col] + else: + d += fabs(val1 - val2) - distances[row1, row2] = d + distances[row1, row2] = d if not two_tables: _lower_to_symmetric(distances) @@ -209,35 +210,36 @@ def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): n_rows, n_cols = x.shape[0], x.shape[1] distances = np.zeros((n_cols, n_cols), dtype=float) - for col1 in range(n_cols): - for col2 in range(col1): - d = 0 - for row in range(n_rows): - val1, val2 = x[row, col1], x[row, col2] - if normalize: - val1 = (val1 - medians[col1]) / (2 * mads[col1]) - val2 = (val2 - medians[col2]) / (2 * mads[col2]) - if npy_isnan(val1): - if npy_isnan(val2): - d += 1 + with nogil: + for col1 in range(n_cols): + for col2 in range(col1): + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if normalize: + val1 = (val1 - medians[col1]) / (2 * mads[col1]) + val2 = (val2 - medians[col2]) / (2 * mads[col2]) + if npy_isnan(val1): + if npy_isnan(val2): + d += 1 + else: + d += fabs(val2) + 0.5 + elif npy_isnan(val2): + d += fabs(val1) + 0.5 else: - d += fabs(val2) + 0.5 - elif npy_isnan(val2): - d += fabs(val1) + 0.5 + d += fabs(val1 - val2) else: - d += fabs(val1 - val2) - else: - if npy_isnan(val1): - if npy_isnan(val2): - d += mads[col1] + mads[col2] \ - + fabs(medians[col1] - medians[col2]) + if npy_isnan(val1): + if npy_isnan(val2): + d += mads[col1] + mads[col2] \ + + fabs(medians[col1] - medians[col2]) + else: + d += fabs(val2 - medians[col1]) + mads[col1] + elif npy_isnan(val2): + d += fabs(val1 - medians[col2]) + mads[col2] else: - d += fabs(val2 - medians[col1]) + mads[col1] - elif npy_isnan(val2): - d += fabs(val1 - medians[col2]) + mads[col2] - else: - d += fabs(val1 - val2) - distances[col1, col2] = distances[col2, col1] = d + d += fabs(val1 - val2) + distances[col1, col2] = distances[col2, col1] = d return distances @@ -474,36 +476,37 @@ def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): n_rows, n_cols = x.shape[0], x.shape[1] distances = np.zeros((n_cols, n_cols), dtype=float) - for col1 in range(n_cols): - for col2 in range(col1): - in_both = in_one = 0 - in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - for row in range(n_rows): - val1, val2 = x[row, col1], x[row, col2] - if npy_isnan(val1): - if npy_isnan(val2): - unk1_unk2 += 1 - elif val2 != 0: - unk1_in2 += 1 - else: - unk1_not2 += 1 - elif npy_isnan(val2): - if val1 != 0: - in1_unk2 += 1 + with nogil: + for col1 in range(n_cols): + for col2 in range(col1): + in_both = in_one = 0 + in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if npy_isnan(val1): + if npy_isnan(val2): + unk1_unk2 += 1 + elif val2 != 0: + unk1_in2 += 1 + else: + unk1_not2 += 1 + elif npy_isnan(val2): + if val1 != 0: + in1_unk2 += 1 + else: + not1_unk2 += 1 else: - not1_unk2 += 1 - else: - if val1 != 0 and val2 != 0: - in_both += 1 - elif val1 != 0 or val2 != 0: - in_one += 1 - distances[col1, col2] = distances[col2, col1] = \ - 1 - float(in_both - + ps[col1] * unk1_in2 + - + ps[col2] * in1_unk2 + - + ps[col1] * ps[col2] * unk1_unk2) / \ - (in_both + in_one + unk1_in2 + in1_unk2 + - + ps[col1] * unk1_not2 - + ps[col2] * not1_unk2 - + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + if val1 != 0 and val2 != 0: + in_both += 1 + elif val1 != 0 or val2 != 0: + in_one += 1 + distances[col1, col2] = distances[col2, col1] = \ + 1 - float(in_both + + ps[col1] * unk1_in2 + + + ps[col2] * in1_unk2 + + + ps[col1] * ps[col2] * unk1_unk2) / \ + (in_both + in_one + unk1_in2 + in1_unk2 + + + ps[col1] * unk1_not2 + + ps[col2] * not1_unk2 + + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) return distances From 2d18d7058d39a7ac9e6b9846eb07502fe2477ecd Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 14 Jul 2017 00:31:51 +0200 Subject: [PATCH 14/27] distances: Fix tests for OWDistance --- .../unsupervised/tests/test_owdistances.py | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Orange/widgets/unsupervised/tests/test_owdistances.py b/Orange/widgets/unsupervised/tests/test_owdistances.py index f5f6b7d320d..d54f9c49147 100644 --- a/Orange/widgets/unsupervised/tests/test_owdistances.py +++ b/Orange/widgets/unsupervised/tests/test_owdistances.py @@ -5,7 +5,6 @@ import numpy as np from Orange.data import Table -from Orange.distance import MahalanobisDistance from Orange.widgets.unsupervised.owdistances import OWDistances, METRICS from Orange.widgets.tests.base import WidgetTest @@ -24,9 +23,7 @@ def test_distance_combo(self): """Check distances when the metric changes""" self.assertEqual(self.widget.metrics_combo.count(), len(METRICS)) self.send_signal(self.widget.Inputs.data, self.iris) - for i, metric in enumerate(METRICS): - if isinstance(metric, MahalanobisDistance): - metric = MahalanobisDistance(self.iris) + for i, (_, metric) in enumerate(METRICS): self.widget.metrics_combo.activated.emit(i) self.widget.metrics_combo.setCurrentIndex(i) self.send_signal(self.widget.Inputs.data, self.iris) @@ -36,6 +33,7 @@ def test_distance_combo(self): def test_error_message(self): """Check if error message appears and then disappears when data is removed from input""" + self.widget.metric_idx = 2 self.send_signal(self.widget.Inputs.data, self.iris) self.assertFalse(self.widget.Error.no_continuous_features.is_shown()) self.send_signal(self.widget.Inputs.data, self.titanic) @@ -43,28 +41,6 @@ def test_error_message(self): self.send_signal(self.widget.Inputs.data, None) self.assertFalse(self.widget.Error.no_continuous_features.is_shown()) - def test_mahalanobis_error(self): - mah_index = [i for i, d in enumerate(METRICS) - if isinstance(d, MahalanobisDistance)][0] - self.widget.metric_idx = mah_index - self.widget.autocommit = True - - invalid = self.iris[:] - invalid.X = np.vstack((invalid.X[0], invalid.X[0])) - invalid.Y = np.vstack((invalid.Y[0], invalid.Y[0])) - datasets = [self.iris, None, invalid] - bad = [False, False, True] - out = [True, False, False] - - for data1, bad1, out1 in zip(datasets, bad, out): - for data2, bad2, out2 in zip(datasets, bad, out): - self.send_signal(self.widget.Inputs.data, data1) - self.assertEqual(self.widget.Error.mahalanobis_error.is_shown(), bad1) - self.assertEqual(self.get_output(self.widget.Outputs.distances) is not None, out1) - self.send_signal(self.widget.Inputs.data, data2) - self.assertEqual(self.widget.Error.mahalanobis_error.is_shown(), bad2) - self.assertEqual(self.get_output(self.widget.Outputs.distances) is not None, out2) - def test_too_big_array(self): """ Users sees an error message when calculating too large arrays and Orange From e32fb0d55599dc8e4702d19d8372e8a3ec0561a3 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 14 Jul 2017 15:00:53 +0200 Subject: [PATCH 15/27] distances: Make DistanceModel.axis a read-only property --- Orange/distance/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 78167c59490..75be1e18970 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -89,9 +89,13 @@ def fit(self, e1): class DistanceModel: def __init__(self, axis, impute=False): - self.axis = axis + self._axis = axis self.impute = impute + @property + def axis(self): + return self._axis + def __call__(self, e1, e2=None): """ If e2 is omitted, calculate distances between all rows (axis=1) or From 43429311a695f614d4b2af982c3919d8e687d784 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 14 Jul 2017 15:48:20 +0200 Subject: [PATCH 16/27] distances: Move attribute to the base class --- Orange/distance/__init__.py | 44 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 75be1e18970..31dd3a02f16 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -120,6 +120,8 @@ def __call__(self, e1, e2=None): x1 = _orange_to_numpy(e1) x2 = _orange_to_numpy(e2) dist = self.compute_distances(x1, x2) + if self.impute and np.isnan(dist).any(): + dist = np.nan_to_num(dist) if isinstance(e1, Table) or isinstance(e1, RowInstance): dist = DistMatrix(dist, e1, e2, self.axis) else: @@ -131,7 +133,7 @@ def compute_distances(self, x1, x2): class FittedDistanceModel(DistanceModel): - def __init__(self, attributes, axis, impute=False, fit_params=None): + def __init__(self, attributes, axis=1, impute=False, fit_params=None): super().__init__(axis, impute) self.attributes = attributes self.fit_params = fit_params @@ -219,6 +221,8 @@ def __call__(self, e1, e2=None, axis=1, impute=False): x2 = x2.T dist = skl_metrics.pairwise.pairwise_distances( x1, x2, metric=self.metric) + if impute and np.isnan(dist).any(): + dist = np.nan_to_num(dist) if isinstance(e1, Table) or isinstance(e1, RowInstance): dist_matrix = DistMatrix(dist, e1, e2, axis) else: @@ -238,9 +242,8 @@ class Euclidean(FittedDistance): fallback = SklDistance('euclidean', 'Euclidean', True) ModelType = EuclideanModel - def __new__(cls, *args, **kwargs): - kwargs.setdefault("normalize", False) - return super().__new__(cls, *args, **kwargs) + def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): + return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def fit_rows(self, x, n_vals): super().fit_rows(x, n_vals) @@ -298,9 +301,8 @@ class Manhattan(FittedDistance): fallback = SklDistance('manhattan', 'Manhattan', True) ModelType = ManhattanModel - def __new__(cls, *args, **kwargs): - kwargs.setdefault("normalize", False) - return super().__new__(cls, *args, **kwargs) + def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): + return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def fit_rows(self, x, n_vals): super().fit_rows(x, n_vals) @@ -356,10 +358,6 @@ class Cosine(FittedDistance): fallback = SklDistance('cosine', 'Cosine', True) ModelType = CosineModel - def __new__(cls, *args, **kwargs): - kwargs.setdefault("normalize", False) - return super().__new__(cls, *args, **kwargs) - def fit_rows(self, x, n_vals): super().fit_rows(x, n_vals) n, n_cols = x.shape @@ -417,8 +415,6 @@ def compute_distances(self, x1, x2): if x2 is None: x2 = x1 rho = self.compute_correlation(x1, x2) - if np.isnan(rho).any() and impute: - rho = np.nan_to_num(rho) if self.absolute: return (1. - np.abs(rho)) / 2. else: @@ -443,12 +439,12 @@ class CorrelationDistance(Distance): class SpearmanR(CorrelationDistance): def fit(self, _): - return SpearmanModel(False, self.axis, getattr(self, "impute", False)) + return SpearmanModel(False, self.axis, self.impute) class SpearmanRAbsolute(CorrelationDistance): def fit(self, _): - return SpearmanModel(True, self.axis, getattr(self, "impute", False)) + return SpearmanModel(True, self.axis, self.impute) class PearsonModel(CorrelationDistanceModel): @@ -461,12 +457,12 @@ def compute_correlation(self, x1, x2): class PearsonR(CorrelationDistance): def fit(self, _): - return PearsonModel(False, self.axis, getattr(self, "impute", False)) + return PearsonModel(False, self.axis, self.impute) class PearsonRAbsolute(CorrelationDistance): def fit(self, _): - return PearsonModel(True, self.axis, getattr(self, "impute", False)) + return PearsonModel(True, self.axis, self.impute) class Mahalanobis(Distance): @@ -485,17 +481,16 @@ def fit(self, data): vi = np.linalg.inv(c) except: raise ValueError("Computation of inverse covariance matrix failed.") - return MahalanobisModel(self.axis, getattr(self, "impute", False), vi) + return MahalanobisModel(self.axis, self.impute, vi) class MahalanobisModel(DistanceModel): def __init__(self, axis, impute, vi): - super().__init__(axis) - self.impute = impute + super().__init__(axis, impute) self.vi = vi def __call__(self, e1, e2=None, impute=None): - # backward compatibility + # argument `impute` is here just for backward compatibility; don't use if impute is not None: self.impute = impute return super().__call__(e1, e2) @@ -508,16 +503,11 @@ def compute_distances(self, x1, x2): if x1.shape[1] != self.vi.shape[0] or \ x2 is not None and x2.shape[1] != self.vi.shape[0]: raise ValueError('Incorrect number of features.') - - dist = skl_metrics.pairwise.pairwise_distances( + return skl_metrics.pairwise.pairwise_distances( x1, x2, metric='mahalanobis', VI=self.vi) - if np.isnan(dist).any() and self.impute: - dist = np.nan_to_num(dist) - return dist # Backward compatibility - class MahalanobisDistance: def __new__(cls, data=None, axis=1, _='Mahalanobis'): if data is None: From 868e733a37bbf1978dfe643edbaee65d670075c1 Mon Sep 17 00:00:00 2001 From: janezd Date: Sat, 15 Jul 2017 09:54:46 +0200 Subject: [PATCH 17/27] OWSilhouettePlot: Remove code needed for old distances --- Orange/widgets/visualize/owsilhouetteplot.py | 24 ++++---------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Orange/widgets/visualize/owsilhouetteplot.py b/Orange/widgets/visualize/owsilhouetteplot.py index 9fe1aafaada..f38fe02ef67 100644 --- a/Orange/widgets/visualize/owsilhouetteplot.py +++ b/Orange/widgets/visualize/owsilhouetteplot.py @@ -93,9 +93,7 @@ def __init__(self): super().__init__() #: The input data self.data = None # type: Optional[Orange.data.Table] - #: Data after any applied pre-processing step - self._effective_data = None # type: Optional[Orange.data.Table] - #: Distance matrix computed from _effective_data + #: Distance matrix computed from data self._matrix = None # type: Optional[Orange.misc.DistMatrix] #: An bool mask (size == len(data)) indicating missing group/cluster #: assignments @@ -179,19 +177,9 @@ def set_data(self, data): v for v in data.domain.variables + data.domain.metas if v.is_discrete and len(v.values) >= 2] if not candidatevars: - error_msg = "Input does not have any suitable cluster labels." + error_msg = "Input does not have any suitable labels." data = None - if data is not None: - ncont = sum(v.is_continuous for v in data.domain.attributes) - ndiscrete = len(data.domain.attributes) - ncont - if ncont == 0: - data = None - error_msg = "No continuous columns" - elif ncont < len(data.domain.attributes): - warning_msg = "{0} categorical columns will not be used for " \ - "distance computation".format(ndiscrete) - self.data = data if data is not None: self.cluster_var_model[:] = candidatevars @@ -204,14 +192,13 @@ def set_data(self, data): annotvars = [var for var in data.domain.metas if var.is_string] self.annotation_var_model[:] = ["None"] + annotvars self.annotation_var_idx = 1 if len(annotvars) else 0 - self._effective_data = Orange.distance._preprocess(data) self.openContext(Orange.data.Domain(candidatevars)) self.error(error_msg) self.warning(warning_msg) def handleNewSignals(self): - if self._effective_data is not None: + if self.data is not None: self._update() self._replot() @@ -222,7 +209,6 @@ def clear(self): Clear the widget state. """ self.data = None - self._effective_data = None self._matrix = None self._mask = None self._silhouette = None @@ -260,10 +246,10 @@ def _update(self): self._reset_all() return - if self._matrix is None and self._effective_data is not None: + if self._matrix is None and self.data is not None: _, metric = self.Distances[self.distance_idx] try: - self._matrix = np.asarray(metric(self._effective_data)) + self._matrix = np.asarray(metric(self.data)) except MemoryError: self.Error.memory_error() return From 689b4068b9a4ceec32c2d1cd626a74de8f9e6648 Mon Sep 17 00:00:00 2001 From: janezd Date: Sat, 15 Jul 2017 09:56:02 +0200 Subject: [PATCH 18/27] distances: Update documentation --- Orange/distance/__init__.py | 317 +++++++++++++++--- .../source/reference/distance.rst | 178 +++++++++- 2 files changed, 436 insertions(+), 59 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 31dd3a02f16..38fb6be2752 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -31,7 +31,10 @@ def _preprocess(table, impute=True): return new_data +# TODO I have put this function here as a substitute the above `_preprocess`. +# None of them really belongs here; (re?)move them, eventually. def remove_discrete_features(data): + """Remove discrete columns from the data.""" new_domain = Domain( [a for a in data.domain.attributes if a.is_continuous], data.domain.class_vars, @@ -40,12 +43,15 @@ def remove_discrete_features(data): def impute(data): + """Impute missing values.""" return SklImpute()(data) def _orange_to_numpy(x): - """Convert :class:`Orange.data.Table` and :class:`Orange.data.RowInstance` - to :class:`numpy.ndarray`. + """ + Return :class:`numpy.ndarray` (dense or sparse) with attribute data + from the given instance of :class:`Orange.data.Table`, + :class:`Orange.data.RowInstance` or :class:`Orange.data.Instance`. . """ if isinstance(x, Table): return x.X @@ -58,36 +64,135 @@ def _orange_to_numpy(x): class Distance: + """ + Base class for construction of distances models (:obj:`DistanceModel`). + + Distances can be computed between all pairs of rows in one table, or + between pairs where one row is from one table and one from another. + + If `axis` is set to `0`, the class computes distances between all pairs + of columns in a table. Distances between columns from separate tables are + probably meaningless, thus unsupported. + + The class can be used as follows: + + - Constructor is called only with keyword argument `axis` that + specifies the axis over which the distances are computed, and with other + subclass-specific keyword arguments. + - Next, we call the method `fit(data)` to produce an instance of + :obj:`DistanceModel`; the instance stores any parameters needed for + computation of distances, such as statistics for normalization and + handling of missing data. + - We can then call the :obj:`DistanceModel` with data to compute the + distance between its rows or columns, or with two data tables to + compute distances between all pairs of rows. + + The second, shorter way to use this class is to call the constructor with + one or two data tables and any additional keyword arguments. Constructor + will execute the above steps and return :obj:`~Orange.misc.DistMatrix`. + Such usage is here for backward compatibility, practicality and efficiency. + + Args: + e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`): + data on which to train the model and compute the distances + e2 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`): + if present, the class computes distances with pairs coming from + the two tables + axis (int): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + + Attributes: + axis (int): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers. + + The capabilities of the metrics are described with class attributes. + + If class attribute `supports_discrete` is `True`, the distance + also uses discrete attributes to compute row distances. The use of discrete + attributes depends upon the type of distance; e.g. Jaccard distance observes + whether the value is zero or non-zero, while Euclidean and Manhattan + distance observes whether a pair of values is same or different. + + Class attribute `supports_missing` indicates that the distance can cope + with missing data. In such cases, letting the distance handle it should + be preferred over pre-imputation of missing values. + + Class attribute `supports_normalization` indicates that the constructor + accepts an argument `normalize`. If set to `True`, the metric will attempt + to normalize the values in a sense that each attribute will have equal + influence. For instance, the Euclidean distance subtract the mean and + divides the result by the deviation, while Manhattan distance uses the + median and MAD. + + If class attribute `supports_sparse` is `True`, the class will handle + sparse data. Currently, all classes that do handle it rely on fallbacks to + SKL metrics. These, however, do not support discrete data and missing + values, and will fail silently. + """ supports_sparse = False supports_discrete = False supports_normalization = False supports_missing = True - def __new__(cls, e1=None, e2=None, axis=1, **kwargs): + def __new__(cls, e1=None, e2=None, axis=1, impute=False, **kwargs): self = super().__new__(cls) self.axis = axis - # Ugly, but needed for backwards compatibility hack below, to allow - # setting parameters like 'normalize' + self.impute = impute + # Ugly, but needed to allow allow setting subclass-specific parameters + # (such as normalize) when `e1` is not `None` and the `__new__` in the + # subclass is skipped self.__dict__.update(**kwargs) if e1 is None: return self - # Handling sparse data and maintaining backwards compatibility with - # old-style calls + # Fallbacks for sparse data and numpy tables. Remove when subclasses + # no longer use fallbacks for sparse data, and handling numpy tables + # becomes obsolete (or handled elsewhere) if (not hasattr(e1, "domain") or hasattr(e1, "is_sparse") and e1.is_sparse()): fallback = getattr(self, "fallback", None) if fallback is not None: - return fallback(e1, e2, axis, - impute=kwargs.get("impute", False)) + return fallback(e1, e2, axis, impute) + + # Magic constructor model = self.fit(e1) return model(e1, e2) def fit(self, e1): + """ + Return a :obj:`DistanceModel` fit to the data. Must be implemented in + subclasses. + + Args: + e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or + :obj:`np.ndarray` or `None`: + data on which to train the model and compute the distances + + Returns: `DistanceModel` + """ pass class DistanceModel: + """ + Base class for classes that compute distances between data rows or columns. + Instances of these classes are not constructed directly but returned by + the corresponding instances of :obj:`Distance`. + + Attributes: + axis (int, readonly): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers + + """ def __init__(self, axis, impute=False): self._axis = axis self.impute = impute @@ -101,12 +206,17 @@ def __call__(self, e1, e2=None): If e2 is omitted, calculate distances between all rows (axis=1) or columns (axis=2) of e1. If e2 is present, calculate distances between all pairs if rows from e1 and e2. + + This method converts the data into numpy arrays, calls the method + `compute_data` and packs the result into `DistMatrix`. Subclasses are + expected to define the `compute_data` and not the `__call__` method. Args: - e1 (Orange.data.Table or Orange.data.RowInstance or numpy.ndarray): + e1 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): input data - e2 (Orange.data.Table or Orange.data.RowInstance or numpy.ndarray): + e2 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): secondary data + Returns: A distance matrix (Orange.misc.distmatrix.DistMatrix) """ @@ -129,22 +239,53 @@ def __call__(self, e1, e2=None): return dist def compute_distances(self, x1, x2): + """ + Compute the distance between rows or colums of `x1`, or between rows + of `x1` and `x2`. This method must be implement by subclasses. Do not + call directly.""" pass class FittedDistanceModel(DistanceModel): + """ + Convenient common parent class for distance models with separate methods + for fitting and for computation of distances across rows and columns. + + Results of fitting are packed into a dictionary for easier passing to + Cython function that do the heavy lifting in these classes. + + Attributes: + attributes (list of `Variable`): attributes on which the model was fit + fit_params (dict): data used by the model + + Class attributes: + distance_by_cols: a function that accepts a numpy array and parameters + and returns distances by columns. Usually a Cython function. + distance_by_rows: a function that accepts one or two numpy arrays, + an indicator whether the distances are to be computed within + a single array or between two arrays, and parameters; and + returns distances by columns. Usually a Cython function. + """ def __init__(self, attributes, axis=1, impute=False, fit_params=None): super().__init__(axis, impute) self.attributes = attributes self.fit_params = fit_params def __call__(self, e1, e2=None): + """ + Check the validity of the domains before passing the data to the + inherited method. + """ if e1.domain.attributes != self.attributes or \ e2 is not None and e2.domain.attributes != self.attributes: raise ValueError("mismatching domains") return super().__call__(e1, e2) def compute_distances(self, x1, x2=None): + """ + Compute distances by calling either `distance_by_cols` or + `distance_by_wors` + """ if self.axis == 0: return self.distance_by_cols(x1, self.fit_params) else: @@ -156,6 +297,19 @@ def compute_distances(self, x1, x2=None): class FittedDistance(Distance): + """ + Convenient common parent class for distancess with separate methods for + fitting and for computation of distances across rows and columns. + Results of fitting are packed into a dictionary for easier passing to + Cython function that do the heavy lifting in these classes. + + The class implements a method `fit` that calls either `fit_columns` + or `fit_rows` with the data and the number of values for discrete + attributes. + + Class attribute `ModelType` contains the type of the model returned by + `fit`. + """ ModelType = None #: Option[FittedDistanceModel] def fit(self, data): @@ -181,38 +335,16 @@ def fit_rows(self, x, n_vals): # To be removed as the corresponding functionality is implemented above class SklDistance: - def __init__(self, metric, name, supports_sparse): - """ - Args: - metric: The metric to be used for distance calculation - name (str): Name of the distance - supports_sparse (boolean): Whether this metric works on sparse data - or not. - """ + """ + Wrapper for functions sklearn's metrics. Used only as temporary fallbacks + when `Euclidean`, `Manhattan`, `Cosine` or `Jaccard` are given sparse data + or raw numpy arrays. These classes can't handle discrete or missing data + and normalization. Do not use for wrapping new classes. + """ + def __init__(self, metric): self.metric = metric - self.name = name - self.supports_sparse = supports_sparse def __call__(self, e1, e2=None, axis=1, impute=False): - """ - :param e1: input data instances, we calculate distances between all - pairs - :type e1: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param e2: optional second argument for data instances if provided, - distances between each pair, where first item is from e1 and - second is from e2, are calculated - :type e2: :class:`Orange.data.Table` or - :class:`Orange.data.RowInstance` or :class:`numpy.ndarray` - :param axis: if axis=1 we calculate distances between rows, if axis=0 - we calculate distances between columns - :type axis: int - :param impute: if impute=True all NaN values in matrix are replaced - with 0 - :type impute: bool - :return: the matrix with distances between given examples - :rtype: :class:`Orange.misc.distmatrix.DistMatrix` - """ x1 = _orange_to_numpy(e1) x2 = _orange_to_numpy(e2) if axis == 0: @@ -239,13 +371,31 @@ class Euclidean(FittedDistance): supports_sparse = True # via fallback supports_discrete = True supports_normalization = True - fallback = SklDistance('euclidean', 'Euclidean', True) + fallback = SklDistance('euclidean') ModelType = EuclideanModel def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def fit_rows(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for row distances. Returns a dictionary with the + following keys: + + - means: a means of numeric columns; undefined for discrete + - vars: variances of numeric columns, -1 for discrete, -2 to ignore + - dist_missing: a 2d-array; dist_missing[col, value] is the distance + added for the given `value` in discrete column `col` if the value + for the other row is missing; undefined for numeric columns + - dist_missing2: the value used for distance if both values are missing; + used for discrete and numeric columns + - normalize: set to `self.normalize`, so it is passed to the Cython + function + + A column is marked to be ignored if all its values are nan or if + `self.normalize` is `True` and the variance of the column is 0. + """ super().fit_rows(x, n_vals) n_cols = len(n_vals) n_bins = max(n_vals) @@ -281,6 +431,16 @@ def fit_rows(self, x, n_vals): normalize=int(self.normalize)) def fit_cols(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for columns. Returns a dictionary with the + following keys: + + - means: column means + - vars: column variances + - normalize: set to self.normalize, so it is passed to the Cython + function + """ super().fit_cols(x, n_vals) means = np.nanmean(x, axis=0) vars = np.nanvar(x, axis=0) @@ -298,13 +458,32 @@ class Manhattan(FittedDistance): supports_sparse = True # via fallback supports_discrete = True supports_normalization = True - fallback = SklDistance('manhattan', 'Manhattan', True) + fallback = SklDistance('manhattan') ModelType = ManhattanModel def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def fit_rows(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for row distances. Returns a dictionary with the + following keys: + + - medians: medians of numeric columns; undefined for discrete + - mads: medians of absolute distances from the median for numeric + columns, -1 for discrete, -2 to ignore + - dist_missing: a 2d-array; dist_missing[col, value] is the distance + added for the given `value` in discrete column `col` if the value + for the other row is missing; undefined for numeric columns + - dist_missing2: the value used for distance if both values are missing; + used for discrete and numeric columns + - normalize: set to `self.normalize`, so it is passed to the Cython + function + + A column is marked to be ignored if all its values are nan or if + `self.normalize` is `True` and the median of the column is 0. + """ super().fit_rows(x, n_vals) n_cols = len(n_vals) n_bins = max(n_vals) @@ -337,6 +516,16 @@ def fit_rows(self, x, n_vals): normalize=int(self.normalize)) def fit_cols(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for columns. Returns a dictionary with the + following keys: + + - medians: column medians + - mads: medians of absolute distances from medians + - normalize: set to self.normalize, so it is passed to the Cython + function + """ super().fit_cols(x, n_vals) medians = np.nanmedian(x, axis=0) mads = np.nanmedian(np.abs(x - medians), axis=0) @@ -355,10 +544,25 @@ class CosineModel(FittedDistanceModel): class Cosine(FittedDistance): supports_sparse = True # via fallback supports_discrete = True - fallback = SklDistance('cosine', 'Cosine', True) + fallback = SklDistance('cosine') ModelType = CosineModel def fit_rows(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for row and column based distances. Although the + computation is asymmetric, the same statistics are needed in both cases. + + Returns a dictionary with the following keys: + + - means: means of numeric columns; relative frequencies of non-zero + values for discrete + - vars: variances of numeric columns, -1 for discrete, -2 to ignore + - dist_missing2: the value used for distance if both values are missing; + used for discrete and numeric columns + + A column is marked to be ignored if all its values are nan. + """ super().fit_rows(x, n_vals) n, n_cols = x.shape means = np.zeros(n_cols, dtype=float) @@ -394,10 +598,20 @@ class JaccardModel(FittedDistanceModel): class Jaccard(FittedDistance): supports_sparse = False supports_discrete = True - fallback = SklDistance('jaccard', 'Jaccard', True) + fallback = SklDistance('jaccard') ModelType = JaccardModel def fit_rows(self, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for row and column based distances. Although the + computation is asymmetric, the same statistics are needed in both cases. + + Returns a dictionary with the following key: + + - ps: relative freuenceies of non-zero values + """ + return { "ps": np.fromiter( (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), @@ -407,6 +621,7 @@ def fit_rows(self, x, n_vals): class CorrelationDistanceModel(DistanceModel): + """Helper class for normal and absolute Pearson and Spearman correlation""" def __init__(self, absolute, axis=1, impute=False): super().__init__(axis, impute) self.absolute = absolute @@ -470,6 +685,7 @@ class Mahalanobis(Distance): supports_missing = False def fit(self, data): + """Return a model with stored inverse covariance matrix""" x = _orange_to_numpy(data) if self.axis == 0: x = x.T @@ -507,8 +723,19 @@ def compute_distances(self, x1, x2): x1, x2, metric='mahalanobis', VI=self.vi) -# Backward compatibility +# TODO: Appears to have been used only in the Distances widget (where it had +# to be handled as a special case and is now replaced with the above class) +# and in tests. Remove? class MahalanobisDistance: + """ + Obsolete class needed for backward compatibility. + + Previous implementation of instances did not have a separate fitting phase, + except for MahalanobisDistance, which was implemented in a single class + but required first (explicitly) calling the method 'fit'. The backward + compatibility hack in :obj:`Distance` cannot handle such use, hence it + is provided in this class. + """ def __new__(cls, data=None, axis=1, _='Mahalanobis'): if data is None: return cls diff --git a/doc/data-mining-library/source/reference/distance.rst b/doc/data-mining-library/source/reference/distance.rst index bdc832086a5..91dbb654b48 100644 --- a/doc/data-mining-library/source/reference/distance.rst +++ b/doc/data-mining-library/source/reference/distance.rst @@ -2,7 +2,8 @@ Distance (``distance``) ####################### -The following example demonstrates how to compute distances between all examples: +The following example demonstrates how to compute distances between all data +instances from Iris: >>> from Orange.data import Table >>> from Orange.distance import Euclidean @@ -12,22 +13,171 @@ The following example demonstrates how to compute distances between all examples >>> dist_matrix.X[0, 1] 0.53851648 +To compute distances between all columns, we set `axis` to 0. + >>> Euclidean(iris, axis=0) + DistMatrix([[ 0. , 36.17927584, 28.9542743 , 57.1913455 ], + [ 36.17927584, 0. , 25.73382987, 25.81259383], + [ 28.9542743 , 25.73382987, 0. , 33.87270287], + [ 57.1913455 , 25.81259383, 33.87270287, 0. ]]) -The module for `Distance` is based on the popular `scikit-learn`_ and `scipy`_ packages. We wrap the following distance metrics: +Finally, we can compute distances between all pairs of rows from two tables. -- :obj:`Orange.distance.Euclidean` -- :obj:`Orange.distance.Manhattan` -- :obj:`Orange.distance.Cosine` -- :obj:`Orange.distance.Jaccard` -- :obj:`Orange.distance.SpearmanR` -- :obj:`Orange.distance.SpearmanRAbsolute` -- :obj:`Orange.distance.PearsonR` -- :obj:`Orange.distance.PearsonRAbsolute` + >>> iris1 = iris[:100] + >>> iris2 = iris[100:] + >>> dist = Euclidean(iris_even, iris_odd) + >>> dist.shape + (75, 100) -All distances have a common interface to the __call__ method which is the following: +Most metrics can be fit on training data to normalize values and handle missing +data. We do so by calling the constructor without arguments or with parameters, +such as `normalize`, and then pass the data to method `fit`. -.. automethod:: Orange.distance.Distance.__call__ + >>> dist_model = Euclidean(normalize=True).fit(iris1) + >>> dist = dist_model(iris2[:3]) + >>> dist + DistMatrix([[ 0. , 1.36778277, 1.11352233], + [ 1.36778277, 0. , 1.57810546], + [ 1.11352233, 1.57810546, 0. ]]) -.. _`scikit-learn`: http://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise_distances.html#sklearn.metrics.pairwise_distances -.. _`scipy`: http://docs.scipy.org/doc/scipy/reference/stats.html +The above distances are computed on the first three rows of `iris2`, normalized +by means and variances computed from `iris1`. + +Here are five closest neighbors of `iris2[0]` from `iris1`:: + + >>> dist0 = dist_model(iris1, iris2[0]) + >>> neigh_idx = np.argsort(dist0.flatten())[:5] + >>> iris1[neigh_idx] + [[5.900, 3.200, 4.800, 1.800 | Iris-versicolor], + [6.700, 3.000, 5.000, 1.700 | Iris-versicolor], + [6.300, 3.300, 4.700, 1.600 | Iris-versicolor], + [6.000, 3.400, 4.500, 1.600 | Iris-versicolor], + [6.400, 3.200, 4.500, 1.500 | Iris-versicolor] + ] + +All distances share a common interface. + +.. autoclass:: Orange.distance.Distance + +Handling discrete and missing data +================================== + +Discrete data is handled as appropriate for the particular distance. For +instance, the Euclidean distance treats a pair of values as either the same or +different, contributing either 0 or 1 to the squared sum of differences. In +other cases -- particularly in Jaccard and cosine distance, discrete values +are treated as zero or non-zero. + +Missing data is not simply imputed. We assume that values of each variable are +distributed by some unknown distribution and compute - without assuming a +particular distribution shape - the expected distance. +For instance, for the Euclidean distance it turns out that the expected +squared distance between a known and a missing value equals the square of +the known value's distance from the mean of the missing variable, plus its +variance. + + +Supported distances +=================== + +Euclidean distance +------------------ + +For numeric values, the Euclidean distance is the square root of sums of +squares of pairs of values from rows or columns. For discrete values, 1 +is added if the two values are different. + +To put all numeric data on the same scale, and in particular when working +with a mixture of numeric and discrete data, it is recommended to enable +normalization by adding `normalize=True` to the constructor. With this, +numeric values are normalized by subtracting their mean and divided by +deviation multiplied by the square root of two. The mean and deviation are +computed on the training data, if the `fit` method is used. When computing +distances between two tables and without explicitly calling `fit`, means +and variances are computed from the first table only. Means and variances +are always computed from columns, disregarding the axis over which we +compute the distances, since columns represent variables and hence come from +a certain distribution. + +As described above, the expected squared difference between a known and a +missing value equals the squared difference between the known value and the +mean, plus the variance. The squared difference between two unknown values +equals twice the variance. + +For normalized data, the difference between a known and missing numeric value +equals the square of the known value + 0.5. The difference between two +missing values is 1. + +For discrete data, the expected difference between a known and a missing value +equals the probablity that the two values are different, which is 1 minus the +probability of the known value. If both values are missing, the probability +of them being different equals 1 minus the sum of squares of all probabilities +(also known as the Gini index). + + +Manhattan distance +------------------ + +Manhattan distance is the sum of absolute pairwise distances. + +Normalization and treatment of missing values is similar as in the Euclidean +distance, except that medians and median absolute distance from the median +(MAD) are used instead of means and deviations. + +For discrete values, distances are again 0 or 1, hence the Manhattan distance +for discrete columns is the same as the Euclidean. + +Cosine distance +--------------- + +Cosine similarity is the dot product divided by the product +of lengths (where the length is the square of dot product of a row/column with +itself). Cosine distance is computed by subtracting the similarity from one. + +In calculation of dot products, missing values are replaced by means. In +calculation of lengths, the contribution of a missing value equals the square +of the mean plus the variance. (The difference comes from the fact that in +the former case the missing values are independent.) + +Non-zero discrete values are replaced by 1. This introduces the notion of a +"base value", which is the first in the list of possible values. In most cases, +this will only make sense for indicator (i.e. two-valued, boolean attributes). + +Cosine distance does not support any column-wise normalization. + +Jaccard distance +---------------- + +Jaccard similarity between two sets is defined as the size of their +intersection divided by the size of the union. Jaccard distance is computed +by subtracting the similarity from one. + +In Orange, attribute values are interpreted as membership indicator. In +row-wise distances, columns are interpreted as sets, and non-zero +values in a row (including negative values of numeric features) indicate that +the row belongs to the particular sets. In column-wise distances, rows are sets +and values indicate the sets to which the column belongs. + +For missing values, relative frequencies from the training data are used as +probabilities for belonging to a set. That is, for row-wise distances, we +compute the relative frequency of non-zero values in each column, and vice-versa +for column-wise distances. For intersection (union) of sets, we then add the +probability of belonging to both (any of) the two sets instead of adding a +0 or 1. + +SpearmanR, AbsoluteSpearmanR, PearsonR, AbsolutePearsonR +-------------------------------------------------------- + +The four correlation-based distance measure equal (1 - the +correlation coefficient) / 2. For `AbsoluteSpearmanR` and `AbsolutePearsonR`, the +absolute value of the coefficient is used. + +These distances do not handle missing or discrete values. + +Mahalanobis distance +-------------------- + +Mahalanobis distance is similar to cosine distance, except that the data is +projected into the PCA space. + +Mahalanobis distance does not handle missing or discrete values. From 5c0d074e1973460eb54682cadfeb60db1f7e4949 Mon Sep 17 00:00:00 2001 From: janezd Date: Sat, 15 Jul 2017 16:32:36 +0200 Subject: [PATCH 19/27] distances: Speed up Euclidean distance --- Orange/distance/__init__.py | 85 +- Orange/distance/_distance.c | 39713 ++++++++++++++++---------------- Orange/distance/_distance.pyx | 186 +- 3 files changed, 20414 insertions(+), 19570 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 38fb6be2752..7978ec2ab52 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -1,7 +1,7 @@ import numpy as np from scipy import stats import sklearn.metrics as skl_metrics - +from sklearn.utils.extmath import row_norms, safe_sparse_dot from Orange.data import Table, Domain, Instance, RowInstance from Orange.misc import DistMatrix @@ -363,8 +363,87 @@ def __call__(self, e1, e2=None, axis=1, impute=False): class EuclideanModel(FittedDistanceModel): - distance_by_cols = _distance.euclidean_cols - distance_by_rows = _distance.euclidean_rows + def distance_by_rows(self, x1, x2, two_tables, fit_params): + vars = fit_params["vars"] + means = fit_params["means"] + dist_missing = fit_params["dist_missing"] + dist_missing2 = fit_params["dist_missing2"] + normalize = fit_params["normalize"] + + cols = vars >= 0 + if np.any(cols): + if normalize: + data1 = x1[:, cols] + data1 -= means[cols] + data1 /= np.sqrt(2 * vars[cols]) + if two_tables: + data2 = x2[:, cols] + data2 -= means + data2 /= np.sqrt(2 * vars[cols]) + else: + data2 = data1 + elif np.all(cols): + data1, data2 = x1, x2 + else: + data1 = x1[:, cols] + data2 = x2[:, cols] if two_tables else data1 + + # adapted from sklearn.metric.euclidean_distances + xx = row_norms(data1, squared=True)[:, np.newaxis] + if two_tables: + yy = row_norms(data2, squared=True)[np.newaxis, :] + else: + yy = xx.T + distances = safe_sparse_dot(data1, data2.T, dense_output=True) + distances *= -2 + distances += xx + distances += yy + np.maximum(distances, 0, out=distances) + if not two_tables: + distances.flat[::distances.shape[0] + 1] = 0.0 + + if normalize: + _distance.fix_euclidean_rows_normalized(distances, data1, data2, means[cols], vars[cols], dist_missing2[cols], two_tables) + else: + _distance.fix_euclidean_rows(distances, data1, data2, means[cols], vars[cols], dist_missing2[cols], two_tables) + + else: + distances = np.zeros((x1.shape[0], x2.shape[0])) + + cols = vars == -1 + if np.any(cols): + if np.all(cols): + data1, data2 = x1, x2 + else: + data1 = x1[:, cols] + data2 = x2[:, cols] if two_tables else data1 + _distance.euclidean_rows_discrete(distances, data1, data2, dist_missing[cols], dist_missing2[cols], two_tables) + + return np.sqrt(distances) + + def distance_by_cols(self, x1, fit_params): + vars = fit_params["vars"] + means = fit_params["means"] + normalize = fit_params["normalize"] + + if normalize: + x1 = x1 - means + x1 /= np.sqrt(2 * vars) + + # adapted from sklearn.metric.euclidean_distances + xx = row_norms(x1.T, squared=True)[:, np.newaxis] + distances = safe_sparse_dot(x1.T, x1, dense_output=True) + distances *= -2 + distances += xx + distances += xx.T + np.maximum(distances, 0, out=distances) + distances.flat[::distances.shape[0] + 1] = 0.0 + + if normalize: + _distance.fix_euclidean_cols_normalized(distances, x1, means, vars) + else: + _distance.fix_euclidean_cols(distances, x1, means, vars) + return np.sqrt(distances) class Euclidean(FittedDistance): diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index 8daec239199..84b6b1d69d5 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -519,16 +519,6 @@ static const char *__pyx_f[] = { "stringsource", "type.pxd", }; -/* MemviewSliceStruct.proto */ -struct __pyx_memoryview_obj; -typedef struct { - struct __pyx_memoryview_obj *memview; - char *data; - Py_ssize_t shape[8]; - Py_ssize_t strides[8]; - Py_ssize_t suboffsets[8]; -} __Pyx_memviewslice; - /* BufferFormatStructs.proto */ #define IS_UNSIGNED(type) (((type) -1) > 0) struct __Pyx_StructField_; @@ -565,6 +555,16 @@ typedef struct { char is_valid_array; } __Pyx_BufFmt_Context; +/* MemviewSliceStruct.proto */ +struct __pyx_memoryview_obj; +typedef struct { + struct __pyx_memoryview_obj *memview; + char *data; + Py_ssize_t shape[8]; + Py_ssize_t strides[8]; + Py_ssize_t suboffsets[8]; +} __Pyx_memviewslice; + /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS @@ -1076,6 +1076,22 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + /* BufferFormatCheck.proto */ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); @@ -1085,6 +1101,8 @@ static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type); // PROTO +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) /* MemviewSliceInit.proto */ #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d #define __Pyx_MEMVIEW_DIRECT 1 @@ -1111,28 +1129,6 @@ static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - /* PyThreadStateGet.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; @@ -1157,41 +1153,33 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif -/* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* BufferFallbackError.proto */ static void __Pyx_RaiseBufferFallbackError(void); +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { @@ -1377,6 +1365,11 @@ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); #define __PYX_FORCE_INIT_THREADS 0 #endif +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); @@ -1438,13 +1431,33 @@ static int __pyx_slices_overlap(__Pyx_memviewslice *slice1, /* Capsule.proto */ static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig); -/* MemviewDtypeToObject.proto */ -static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp); -static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj); +/* TypeInfoCompare.proto */ +static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b); + +/* MemviewSliceValidateAndInit.proto */ +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj); + +/* ObjectToMemviewSlice.proto */ +static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *); + +/* ObjectToMemviewSlice.proto */ +static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); +/* MemviewDtypeToObject.proto */ +static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp); +static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj); + /* None.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus @@ -1570,26 +1583,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -/* TypeInfoCompare.proto */ -static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b); - -/* MemviewSliceValidateAndInit.proto */ -static int __Pyx_ValidateAndInit_memviewslice( - int *axes_specs, - int c_or_f_flag, - int buf_flags, - int ndim, - __Pyx_TypeInfo *dtype, - __Pyx_BufFmt_StackElem stack[], - __Pyx_memviewslice *memviewslice, - PyObject *original_obj); - -/* ObjectToMemviewSlice.proto */ -static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *); - -/* ObjectToMemviewSlice.proto */ -static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *); - /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1722,7 +1715,6 @@ static const char __pyx_k_np[] = "np"; static const char __pyx_k_ps[] = "ps"; static const char __pyx_k_x1[] = "x1"; static const char __pyx_k_x2[] = "x2"; -static const char __pyx_k_all[] = "all"; static const char __pyx_k_col[] = "col"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_row[] = "row"; @@ -1742,7 +1734,6 @@ static const char __pyx_k_pack[] = "pack"; static const char __pyx_k_row1[] = "row1"; static const char __pyx_k_row2[] = "row2"; static const char __pyx_k_size[] = "size"; -static const char __pyx_k_sqrt[] = "sqrt"; static const char __pyx_k_step[] = "step"; static const char __pyx_k_stop[] = "stop"; static const char __pyx_k_test[] = "__test__"; @@ -1755,7 +1746,6 @@ static const char __pyx_k_dtype[] = "dtype"; static const char __pyx_k_empty[] = "empty"; static const char __pyx_k_error[] = "error"; static const char __pyx_k_flags[] = "flags"; -static const char __pyx_k_isnan[] = "isnan"; static const char __pyx_k_ival1[] = "ival1"; static const char __pyx_k_ival2[] = "ival2"; static const char __pyx_k_means[] = "means"; @@ -1809,23 +1799,26 @@ static const char __pyx_k_jaccard_cols[] = "jaccard_cols"; static const char __pyx_k_jaccard_rows[] = "jaccard_rows"; static const char __pyx_k_dist_missing2[] = "dist_missing2"; static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; -static const char __pyx_k_euclidean_cols[] = "euclidean_cols"; -static const char __pyx_k_euclidean_rows[] = "euclidean_rows"; static const char __pyx_k_manhattan_cols[] = "manhattan_cols"; static const char __pyx_k_manhattan_rows[] = "manhattan_rows"; static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; +static const char __pyx_k_fix_euclidean_cols[] = "fix_euclidean_cols"; +static const char __pyx_k_fix_euclidean_rows[] = "fix_euclidean_rows"; static const char __pyx_k_strided_and_direct[] = ""; static const char __pyx_k_strided_and_indirect[] = ""; static const char __pyx_k_contiguous_and_direct[] = ""; static const char __pyx_k_MemoryView_of_r_object[] = ""; static const char __pyx_k_MemoryView_of_r_at_0x_x[] = ""; static const char __pyx_k_contiguous_and_indirect[] = ""; +static const char __pyx_k_euclidean_rows_discrete[] = "euclidean_rows_discrete"; static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'"; static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d."; static const char __pyx_k_Orange_distance__distance[] = "Orange.distance._distance"; static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized"; +static const char __pyx_k_fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized"; static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static const char __pyx_k_strided_and_direct_or_indirect[] = ""; static const char __pyx_k_Users_janez_Dropbox_orange3_Ora[] = "/Users/janez/Dropbox/orange3/Orange/distance/_distance.pyx"; @@ -1839,7 +1832,6 @@ static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, ex static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)"; static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object"; -static const char __pyx_k_cannot_normalize_the_data_has_no[] = "cannot normalize: the data has no variance"; static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)"; static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides."; @@ -1871,12 +1863,10 @@ static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_abs1; static PyObject *__pyx_n_s_abs2; static PyObject *__pyx_n_s_abss; -static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_allocate_buffer; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_c; static PyObject *__pyx_n_u_c; -static PyObject *__pyx_kp_s_cannot_normalize_the_data_has_no; static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_col; static PyObject *__pyx_n_s_col1; @@ -1895,9 +1885,12 @@ static PyObject *__pyx_n_s_empty; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; -static PyObject *__pyx_n_s_euclidean_cols; -static PyObject *__pyx_n_s_euclidean_rows; +static PyObject *__pyx_n_s_euclidean_rows_discrete; static PyObject *__pyx_n_s_fit_params; +static PyObject *__pyx_n_s_fix_euclidean_cols; +static PyObject *__pyx_n_s_fix_euclidean_cols_normalized; +static PyObject *__pyx_n_s_fix_euclidean_rows; +static PyObject *__pyx_n_s_fix_euclidean_rows_normalized; static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_fortran; @@ -1909,7 +1902,6 @@ static PyObject *__pyx_n_s_in1_unk2; static PyObject *__pyx_n_s_in_both; static PyObject *__pyx_n_s_in_one; static PyObject *__pyx_n_s_intersection; -static PyObject *__pyx_n_s_isnan; static PyObject *__pyx_n_s_itemsize; static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; static PyObject *__pyx_n_s_ival1; @@ -1951,7 +1943,6 @@ static PyObject *__pyx_n_s_row1; static PyObject *__pyx_n_s_row2; static PyObject *__pyx_n_s_shape; static PyObject *__pyx_n_s_size; -static PyObject *__pyx_n_s_sqrt; static PyObject *__pyx_n_s_start; static PyObject *__pyx_n_s_step; static PyObject *__pyx_n_s_stop; @@ -1977,15 +1968,18 @@ static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_x1; static PyObject *__pyx_n_s_x2; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ @@ -2028,18 +2022,18 @@ static PyObject *__pyx_float_1_0; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_tuple_; +static PyObject *__pyx_slice_; static PyObject *__pyx_slice__2; -static PyObject *__pyx_slice__3; +static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__18; static PyObject *__pyx_slice__19; static PyObject *__pyx_slice__20; -static PyObject *__pyx_slice__21; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; @@ -2048,198 +2042,38 @@ static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__21; static PyObject *__pyx_tuple__22; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__33; -static PyObject *__pyx_tuple__35; -static PyObject *__pyx_tuple__37; -static PyObject *__pyx_tuple__39; -static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__28; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__32; +static PyObject *__pyx_tuple__34; +static PyObject *__pyx_tuple__36; +static PyObject *__pyx_tuple__38; +static PyObject *__pyx_tuple__40; static PyObject *__pyx_tuple__42; -static PyObject *__pyx_tuple__43; static PyObject *__pyx_tuple__44; -static PyObject *__pyx_tuple__45; -static PyObject *__pyx_codeobj__24; -static PyObject *__pyx_codeobj__26; -static PyObject *__pyx_codeobj__28; -static PyObject *__pyx_codeobj__30; -static PyObject *__pyx_codeobj__32; -static PyObject *__pyx_codeobj__34; -static PyObject *__pyx_codeobj__36; -static PyObject *__pyx_codeobj__38; -static PyObject *__pyx_codeobj__40; - -/* "Orange/distance/_distance.pyx":19 - * - * # This function is unused, but kept here for any future use - * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< - * cdef int col - * for col in range(dividers.shape[0]): - */ - -static void __pyx_f_6Orange_8distance_9_distance__check_division_by_zero(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_dividers) { - int __pyx_v_col; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - Py_ssize_t __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - int __pyx_t_11; - __Pyx_RefNannySetupContext("_check_division_by_zero", 0); - - /* "Orange/distance/_distance.pyx":21 - * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): - * cdef int col - * for col in range(dividers.shape[0]): # <<<<<<<<<<<<<< - * if dividers[col] == 0 and not x[:, col].isnan().all(): - * raise ValueError("cannot normalize: the data has no variance") - */ - __pyx_t_1 = (__pyx_v_dividers.shape[0]); - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_col = __pyx_t_2; - - /* "Orange/distance/_distance.pyx":22 - * cdef int col - * for col in range(dividers.shape[0]): - * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< - * raise ValueError("cannot normalize: the data has no variance") - * - */ - __pyx_t_4 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_dividers.data + __pyx_t_4 * __pyx_v_dividers.strides[0]) ))) == 0.0) != 0); - if (__pyx_t_5) { - } else { - __pyx_t_3 = __pyx_t_5; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_8.data = __pyx_v_x.data; - __pyx_t_8.memview = __pyx_v_x.memview; - __PYX_INC_MEMVIEW(&__pyx_t_8, 0); - __pyx_t_8.shape[0] = __pyx_v_x.shape[0]; -__pyx_t_8.strides[0] = __pyx_v_x.strides[0]; - __pyx_t_8.suboffsets[0] = -1; - -{ - Py_ssize_t __pyx_tmp_idx = __pyx_v_col; - Py_ssize_t __pyx_tmp_shape = __pyx_v_x.shape[1]; - Py_ssize_t __pyx_tmp_stride = __pyx_v_x.strides[1]; - if (0 && (__pyx_tmp_idx < 0)) - __pyx_tmp_idx += __pyx_tmp_shape; - if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) { - PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)"); - __PYX_ERR(0, 22, __pyx_L1_error) - } - __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride; -} - -__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - if (__pyx_t_9) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - if (__pyx_t_7) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_11 = ((!__pyx_t_5) != 0); - __pyx_t_3 = __pyx_t_11; - __pyx_L6_bool_binop_done:; - if (__pyx_t_3) { - - /* "Orange/distance/_distance.pyx":23 - * for col in range(dividers.shape[0]): - * if dividers[col] == 0 and not x[:, col].isnan().all(): - * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 23, __pyx_L1_error) - - /* "Orange/distance/_distance.pyx":22 - * cdef int col - * for col in range(dividers.shape[0]): - * if dividers[col] == 0 and not x[:, col].isnan().all(): # <<<<<<<<<<<<<< - * raise ValueError("cannot normalize: the data has no variance") - * - */ - } - } - - /* "Orange/distance/_distance.pyx":19 - * - * # This function is unused, but kept here for any future use - * cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): # <<<<<<<<<<<<<< - * cdef int col - * for col in range(dividers.shape[0]): - */ - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_WriteUnraisable("Orange.distance._distance._check_division_by_zero", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); - __pyx_L0:; - __Pyx_RefNannyFinishContext(); -} - -/* "Orange/distance/_distance.pyx":26 +static PyObject *__pyx_tuple__46; +static PyObject *__pyx_tuple__47; +static PyObject *__pyx_tuple__48; +static PyObject *__pyx_tuple__49; +static PyObject *__pyx_tuple__50; +static PyObject *__pyx_codeobj__23; +static PyObject *__pyx_codeobj__25; +static PyObject *__pyx_codeobj__27; +static PyObject *__pyx_codeobj__29; +static PyObject *__pyx_codeobj__31; +static PyObject *__pyx_codeobj__33; +static PyObject *__pyx_codeobj__35; +static PyObject *__pyx_codeobj__37; +static PyObject *__pyx_codeobj__39; +static PyObject *__pyx_codeobj__41; +static PyObject *__pyx_codeobj__43; +static PyObject *__pyx_codeobj__45; + +/* "Orange/distance/_distance.pyx":18 * * * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< @@ -2261,7 +2095,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi Py_ssize_t __pyx_t_8; __Pyx_RefNannySetupContext("_lower_to_symmetric", 0); - /* "Orange/distance/_distance.pyx":28 + /* "Orange/distance/_distance.pyx":20 * cdef void _lower_to_symmetric(double [:, :] distances): * cdef int row1, row2 * for row1 in range(distances.shape[0]): # <<<<<<<<<<<<<< @@ -2272,7 +2106,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row1 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":29 + /* "Orange/distance/_distance.pyx":21 * cdef int row1, row2 * for row1 in range(distances.shape[0]): * for row2 in range(row1): # <<<<<<<<<<<<<< @@ -2283,7 +2117,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row2 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":30 + /* "Orange/distance/_distance.pyx":22 * for row1 in range(distances.shape[0]): * for row2 in range(row1): * distances[row2, row1] = distances[row1, row2] # <<<<<<<<<<<<<< @@ -2298,7 +2132,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi } } - /* "Orange/distance/_distance.pyx":26 + /* "Orange/distance/_distance.pyx":18 * * * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< @@ -2310,33 +2144,37 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi __Pyx_RefNannyFinishContext(); } -/* "Orange/distance/_distance.pyx":33 +/* "Orange/distance/_distance.pyx":25 * * - * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows[] = "euclidean_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows = {"euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_euclidean_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows_discrete[] = "euclidean_rows_discrete(ndarray distances, ndarray x1, ndarray x2, __Pyx_memviewslice dist_missing, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows_discrete = {"euclidean_rows_discrete", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_euclidean_rows_discrete}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; + __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyArrayObject *__pyx_v_dist_missing2 = 0; char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("euclidean_rows (wrapper)", 0); + __Pyx_RefNannySetupContext("euclidean_rows_discrete (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; - PyObject* values[4] = {0,0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_dist_missing,&__pyx_n_s_dist_missing2,&__pyx_n_s_two_tables,0}; + PyObject* values[6] = {0,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 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); @@ -2347,51 +2185,67 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 1); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 1); __PYX_ERR(0, 25, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 2); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 2); __PYX_ERR(0, 25, __pyx_L3_error) } case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 3); __PYX_ERR(0, 25, __pyx_L3_error) + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, 3); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 4); __PYX_ERR(0, 25, __pyx_L3_error) + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 5); __PYX_ERR(0, 25, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows") < 0)) __PYX_ERR(0, 33, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_rows_discrete") < 0)) __PYX_ERR(0, 25, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { 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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error) - __pyx_v_fit_params = values[3]; + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x1 = ((PyArrayObject *)values[1]); + __pyx_v_x2 = ((PyArrayObject *)values[2]); + __pyx_v_dist_missing = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[3]); if (unlikely(!__pyx_v_dist_missing.memview)) __PYX_ERR(0, 28, __pyx_L3_error) + __pyx_v_dist_missing2 = ((PyArrayObject *)values[4]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[5]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 30, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 33, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 25, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows_discrete", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 33, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 34, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 25, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 26, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 27, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 29, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_dist_missing, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -2402,12 +2256,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -2419,60 +2268,44 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU double __pyx_v_d; int __pyx_v_ival1; int __pyx_v_ival2; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dist_missing2; + __Pyx_Buffer __pyx_pybuffer_dist_missing2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_4; - npy_intp __pyx_t_5; - npy_intp __pyx_t_6; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; int __pyx_t_7; - Py_ssize_t __pyx_t_8; + int __pyx_t_8; Py_ssize_t __pyx_t_9; Py_ssize_t __pyx_t_10; - Py_ssize_t __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; + __pyx_t_5numpy_float64_t __pyx_t_11; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; int __pyx_t_15; - int __pyx_t_16; - int __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; - __pyx_t_5numpy_float64_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - __pyx_t_5numpy_float64_t __pyx_t_27; - int __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - Py_ssize_t __pyx_t_39; - Py_ssize_t __pyx_t_40; - Py_ssize_t __pyx_t_41; - Py_ssize_t __pyx_t_42; - Py_ssize_t __pyx_t_43; - Py_ssize_t __pyx_t_44; - Py_ssize_t __pyx_t_45; - PyObject *__pyx_t_46 = NULL; - __Pyx_RefNannySetupContext("euclidean_rows", 0); + __Pyx_memviewslice __pyx_t_23 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_RefNannySetupContext("euclidean_rows_discrete", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -2481,223 +2314,55 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU __pyx_pybuffer_x2.refcount = 0; __pyx_pybuffernd_x2.data = NULL; __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + __pyx_pybuffer_dist_missing2.pybuffer.buf = NULL; + __pyx_pybuffer_dist_missing2.refcount = 0; + __pyx_pybuffernd_dist_missing2.data = NULL; + __pyx_pybuffernd_dist_missing2.rcbuffer = &__pyx_pybuffer_dist_missing2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error) + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 33, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error) + } + __pyx_pybuffernd_dist_missing2.diminfo[0].strides = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2.diminfo[0].shape = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":38 - * fit_params): - * cdef: - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * double [:] means = fit_params["means"] - * double [:, :] dist_missing = fit_params["dist_missing"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 38, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":39 - * cdef: - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 39, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":40 - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] - * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; - - /* "Orange/distance/_distance.pyx":41 - * double [:] means = fit_params["means"] - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 41, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":42 - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_4; - - /* "Orange/distance/_distance.pyx":49 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":36 + * int ival1, ival2 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * with nogil: */ - __pyx_t_5 = (__pyx_v_x1->dimensions[0]); - __pyx_t_6 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_5; - __pyx_v_n_cols = __pyx_t_6; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":50 + /* "Orange/distance/_distance.pyx":37 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing) == len(dist_missing2) + * with nogil: + * for row1 in range(n_rows1): */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":51 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":52 - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * - */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); - } - } - } - } - - /* "Orange/distance/_distance.pyx":51 + /* "Orange/distance/_distance.pyx":38 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - */ - if (unlikely(!(__pyx_t_7 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 51, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":53 - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing) == len(dist_missing2) - * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * - * with nogil: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); - __pyx_t_1 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 53, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; - - /* "Orange/distance/_distance.pyx":55 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -2709,18 +2374,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":56 - * + /* "Orange/distance/_distance.pyx":39 + * n_rows2 = x2.shape[0] * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): * d = 0 */ - __pyx_t_15 = __pyx_v_n_rows1; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_row1 = __pyx_t_16; + __pyx_t_3 = __pyx_v_n_rows1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":57 + /* "Orange/distance/_distance.pyx":40 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -2728,583 +2393,319 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows(CYTHON_UNU * for col in range(n_cols): */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_17 = __pyx_v_n_rows2; + __pyx_t_5 = __pyx_v_n_rows2; } else { - __pyx_t_17 = __pyx_v_row1; + __pyx_t_5 = __pyx_v_row1; } - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { - __pyx_v_row2 = __pyx_t_18; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":58 + /* "Orange/distance/_distance.pyx":41 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): - * if vars[col] == -2: + * val1, val2 = x1[row1, col], x2[row2, col] */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":59 + /* "Orange/distance/_distance.pyx":42 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * ival1, ival2 = int(val1), int(val2) */ - __pyx_t_19 = __pyx_v_n_cols; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col = __pyx_t_20; + __pyx_t_7 = __pyx_v_n_cols; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_col = __pyx_t_8; - /* "Orange/distance/_distance.pyx":60 + /* "Orange/distance/_distance.pyx":43 * d = 0 * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val1, val2 = x1[row1, col], x2[row2, col] + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): */ - __pyx_t_21 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_7) { + __pyx_t_9 = __pyx_v_row1; + __pyx_t_10 = __pyx_v_col; + __pyx_t_11 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_12 = __pyx_v_row2; + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_11; + __pyx_v_val2 = __pyx_t_14; - /* "Orange/distance/_distance.pyx":61 + /* "Orange/distance/_distance.pyx":44 * for col in range(n_cols): - * if vars[col] == -2: - * continue # <<<<<<<<<<<<<< * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): + * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - goto __pyx_L10_continue; + __pyx_v_ival1 = ((int)__pyx_v_val1); + __pyx_v_ival2 = ((int)__pyx_v_val2); - /* "Orange/distance/_distance.pyx":60 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue + /* "Orange/distance/_distance.pyx":45 * val1, val2 = x1[row1, col], x2[row2, col] + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += dist_missing2[col] */ - } - - /* "Orange/distance/_distance.pyx":62 - * if vars[col] == -2: - * continue - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - */ - __pyx_t_22 = __pyx_v_row1; - __pyx_t_23 = __pyx_v_col; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_25 = __pyx_v_row2; - __pyx_t_26 = __pyx_v_col; - __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_24; - __pyx_v_val2 = __pyx_t_27; - - /* "Orange/distance/_distance.pyx":63 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: - */ - __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_7 = __pyx_t_28; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_7 = __pyx_t_28; - __pyx_L14_bool_binop_done:; - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":64 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif vars[col] == -1: - * ival1, ival2 = int(val1), int(val2) - */ - __pyx_t_29 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - - /* "Orange/distance/_distance.pyx":63 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: - */ - goto __pyx_L13; - } + __pyx_t_15 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_15) { - /* "Orange/distance/_distance.pyx":65 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":46 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * else: */ - __pyx_t_30 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_30 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_7) { + __pyx_t_15 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_15) { - /* "Orange/distance/_distance.pyx":66 - * d += dist_missing2[col] - * elif vars[col] == -1: - * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":47 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * else: * d += dist_missing[col, ival2] */ - __pyx_v_ival1 = ((int)__pyx_v_val1); - __pyx_v_ival2 = ((int)__pyx_v_val2); + __pyx_t_16 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_dist_missing2.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":67 - * elif vars[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":46 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * else: */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":68 - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":49 + * d += dist_missing2[col] + * else: * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - */ - __pyx_t_31 = __pyx_v_col; - __pyx_t_32 = __pyx_v_ival2; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - - /* "Orange/distance/_distance.pyx":67 - * elif vars[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] */ - goto __pyx_L16; + /*else*/ { + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = __pyx_v_ival2; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_17 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_18 * __pyx_v_dist_missing.strides[1]) )))); } + __pyx_L13:; - /* "Orange/distance/_distance.pyx":69 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + /* "Orange/distance/_distance.pyx":45 + * val1, val2 = x1[row1, col], x2[row2, col] + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += dist_missing2[col] */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":70 + /* "Orange/distance/_distance.pyx":50 + * else: * d += dist_missing[col, ival2] - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< - * elif ival1 != ival2: - * d += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - __pyx_t_33 = __pyx_v_col; - __pyx_t_34 = __pyx_v_ival1; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); + __pyx_t_15 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_15) { - /* "Orange/distance/_distance.pyx":69 - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":51 * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< + * elif ival1 != ival2: + * d += 1 */ - goto __pyx_L16; - } + __pyx_t_19 = __pyx_v_col; + __pyx_t_20 = __pyx_v_ival1; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_19 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_20 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":71 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: + /* "Orange/distance/_distance.pyx":50 + * else: + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_7) { + goto __pyx_L12; + } - /* "Orange/distance/_distance.pyx":72 - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - * d += 1 # <<<<<<<<<<<<<< - * elif normalize: - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":52 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * distances[row1, row2] += d */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_t_15 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_15) { - /* "Orange/distance/_distance.pyx":71 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: + /* "Orange/distance/_distance.pyx":53 + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + * d += 1 # <<<<<<<<<<<<<< + * distances[row1, row2] += d + * if not two_tables: */ - } - __pyx_L16:; + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":65 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":52 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * distances[row1, row2] += d */ - goto __pyx_L13; } + __pyx_L12:; + } - /* "Orange/distance/_distance.pyx":73 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - */ - __pyx_t_7 = (__pyx_v_normalize != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":74 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":54 + * elif ival1 != ival2: + * d += 1 + * distances[row1, row2] += d # <<<<<<<<<<<<<< + * if not two_tables: + * _lower_to_symmetric(distances) */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + __pyx_t_21 = __pyx_v_row1; + __pyx_t_22 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_distances.diminfo[1].strides) += __pyx_v_d; + } + } + } - /* "Orange/distance/_distance.pyx":75 - * elif normalize: - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":38 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_35 = __pyx_v_col; - __pyx_t_36 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_35 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_36 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } - /* "Orange/distance/_distance.pyx":74 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":55 + * d += 1 + * distances[row1, row2] += d + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * */ - goto __pyx_L17; - } + __pyx_t_15 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_15) { - /* "Orange/distance/_distance.pyx":76 - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * else: + /* "Orange/distance/_distance.pyx":56 + * distances[row1, row2] += d + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * + * */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); + if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 56, __pyx_L1_error) + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_23); + __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1); - /* "Orange/distance/_distance.pyx":77 - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * elif npy_isnan(val2): - * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * else: - * d += ((val1 - val2) ** 2 / vars[col]) / 2 + /* "Orange/distance/_distance.pyx":55 + * d += 1 + * distances[row1, row2] += d + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * */ - __pyx_t_37 = __pyx_v_col; - __pyx_t_38 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_37 * __pyx_v_means.strides[0]) )))), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_38 * __pyx_v_vars.strides[0]) )))) / 2.0) + 0.5)); + } - /* "Orange/distance/_distance.pyx":76 - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * else: - */ - goto __pyx_L17; - } - - /* "Orange/distance/_distance.pyx":79 - * d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 - * else: - * d += ((val1 - val2) ** 2 / vars[col]) / 2 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): - */ - /*else*/ { - __pyx_t_39 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + ((pow((__pyx_v_val1 - __pyx_v_val2), 2.0) / (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_39 * __pyx_v_vars.strides[0]) )))) / 2.0)); - } - __pyx_L17:; - - /* "Orange/distance/_distance.pyx":73 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":81 - * d += ((val1 - val2) ** 2 / vars[col]) / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += (val2 - means[col]) ** 2 + vars[col] - * elif npy_isnan(val2): - */ - /*else*/ { - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":82 - * else: - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += (val1 - means[col]) ** 2 + vars[col] - */ - __pyx_t_40 = __pyx_v_col; - __pyx_t_41 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_40 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_41 * __pyx_v_vars.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":81 - * d += ((val1 - val2) ** 2 / vars[col]) / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += (val2 - means[col]) ** 2 + vars[col] - * elif npy_isnan(val2): - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":83 - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 + vars[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col]) ** 2 + vars[col] - * else: - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":84 - * d += (val2 - means[col]) ** 2 + vars[col] - * elif npy_isnan(val2): - * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< - * else: - * d += (val1 - val2) ** 2 - */ - __pyx_t_42 = __pyx_v_col; - __pyx_t_43 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_42 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_43 * __pyx_v_vars.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":83 - * if npy_isnan(val1): - * d += (val2 - means[col]) ** 2 + vars[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col]) ** 2 + vars[col] - * else: - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":86 - * d += (val1 - means[col]) ** 2 + vars[col] - * else: - * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< - * distances[row1, row2] = d - * if not two_tables: - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); - } - __pyx_L18:; - } - __pyx_L13:; - __pyx_L10_continue:; - } - - /* "Orange/distance/_distance.pyx":87 - * else: - * d += (val1 - val2) ** 2 - * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) - */ - __pyx_t_44 = __pyx_v_row1; - __pyx_t_45 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } - } - } - - /* "Orange/distance/_distance.pyx":55 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * - * with nogil: # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "Orange/distance/_distance.pyx":88 - * d += (val1 - val2) ** 2 - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return np.sqrt(distances) - */ - __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":89 - * distances[row1, row2] = d - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return np.sqrt(distances) - * - */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - - /* "Orange/distance/_distance.pyx":88 - * d += (val1 - val2) ** 2 - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return np.sqrt(distances) - */ - } - - /* "Orange/distance/_distance.pyx":90 - * if not two_tables: - * _lower_to_symmetric(distances) - * return np.sqrt(distances) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_13, function); - } - } - if (!__pyx_t_12) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - __pyx_t_46 = PyTuple_New(1+1); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_46); - __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_46, 0, __pyx_t_12); __pyx_t_12 = NULL; - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_46, 0+1, __pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0; - } - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":33 - * - * - * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "Orange/distance/_distance.pyx":25 + * + * + * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_XDECREF(__pyx_t_46); + __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.euclidean_rows_discrete", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":93 +/* "Orange/distance/_distance.pyx":59 * * - * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] means = fit_params["means"] + * def fix_euclidean_rows( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_2euclidean_cols[] = "euclidean_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols = {"euclidean_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_2euclidean_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_2fix_euclidean_rows[] = "fix_euclidean_rows(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_3fix_euclidean_rows = {"fix_euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_2fix_euclidean_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + PyArrayObject *__pyx_v_means = 0; + PyArrayObject *__pyx_v_vars = 0; + PyArrayObject *__pyx_v_dist_missing2 = 0; + char __pyx_v_two_tables; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("euclidean_cols (wrapper)", 0); + __Pyx_RefNannySetupContext("fix_euclidean_rows (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_means,&__pyx_n_s_vars,&__pyx_n_s_dist_missing2,&__pyx_n_s_two_tables,0}; + PyObject* values[7] = {0,0,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 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -3313,36 +2714,76 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 1); __PYX_ERR(0, 59, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 2); __PYX_ERR(0, 59, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 3); __PYX_ERR(0, 59, __pyx_L3_error) + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 4); __PYX_ERR(0, 59, __pyx_L3_error) + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 5); __PYX_ERR(0, 59, __pyx_L3_error) + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, 1); __PYX_ERR(0, 93, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 6); __PYX_ERR(0, 59, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "euclidean_cols") < 0)) __PYX_ERR(0, 93, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows") < 0)) __PYX_ERR(0, 59, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + } + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x1 = ((PyArrayObject *)values[1]); + __pyx_v_x2 = ((PyArrayObject *)values[2]); + __pyx_v_means = ((PyArrayObject *)values[3]); + __pyx_v_vars = ((PyArrayObject *)values[4]); + __pyx_v_dist_missing2 = ((PyArrayObject *)values[5]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("euclidean_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 93, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 59, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 93, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 60, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 61, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 62, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 63, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 64, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -3353,180 +2794,139 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_cols(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; - int __pyx_v_n_rows; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; int __pyx_v_n_cols; - int __pyx_v_col1; - int __pyx_v_col2; - int __pyx_v_row; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; double __pyx_v_val1; double __pyx_v_val2; double __pyx_v_d; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x; - __Pyx_Buffer __pyx_pybuffer_x; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dist_missing2; + __Pyx_Buffer __pyx_pybuffer_dist_missing2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; + __Pyx_LocalBuf_ND __pyx_pybuffernd_means; + __Pyx_Buffer __pyx_pybuffer_means; + __Pyx_LocalBuf_ND __pyx_pybuffernd_vars; + __Pyx_Buffer __pyx_pybuffer_vars; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_3; - npy_intp __pyx_t_4; - npy_intp __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; - int __pyx_t_13; - int __pyx_t_14; - int __pyx_t_15; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - __pyx_t_5numpy_float64_t __pyx_t_18; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; Py_ssize_t __pyx_t_20; - __pyx_t_5numpy_float64_t __pyx_t_21; - int __pyx_t_22; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; Py_ssize_t __pyx_t_24; Py_ssize_t __pyx_t_25; Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - Py_ssize_t __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - PyObject *__pyx_t_39 = NULL; - __Pyx_RefNannySetupContext("euclidean_cols", 0); - __pyx_pybuffer_x.pybuffer.buf = NULL; - __pyx_pybuffer_x.refcount = 0; - __pyx_pybuffernd_x.data = NULL; - __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + __Pyx_RefNannySetupContext("fix_euclidean_rows", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + __pyx_pybuffer_means.pybuffer.buf = NULL; + __pyx_pybuffer_means.refcount = 0; + __pyx_pybuffernd_means.data = NULL; + __pyx_pybuffernd_means.rcbuffer = &__pyx_pybuffer_means; + __pyx_pybuffer_vars.pybuffer.buf = NULL; + __pyx_pybuffer_vars.refcount = 0; + __pyx_pybuffernd_vars.data = NULL; + __pyx_pybuffernd_vars.rcbuffer = &__pyx_pybuffer_vars; + __pyx_pybuffer_dist_missing2.pybuffer.buf = NULL; + __pyx_pybuffer_dist_missing2.refcount = 0; + __pyx_pybuffernd_dist_missing2.data = NULL; + __pyx_pybuffernd_dist_missing2.rcbuffer = &__pyx_pybuffer_dist_missing2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 93, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - - /* "Orange/distance/_distance.pyx":95 - * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * double [:] vars = fit_params["vars"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":96 - * cdef: - * double [:] means = fit_params["means"] - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":97 - * double [:] means = fit_params["means"] - * double [:] vars = fit_params["vars"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, col1, col2, row - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_3; + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + } + __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + } + __pyx_pybuffernd_vars.diminfo[0].strides = __pyx_pybuffernd_vars.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vars.diminfo[0].shape = __pyx_pybuffernd_vars.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + } + __pyx_pybuffernd_dist_missing2.diminfo[0].strides = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2.diminfo[0].shape = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":103 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":71 + * double val1, val2, d * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] * with nogil: */ - __pyx_t_4 = (__pyx_v_x->dimensions[0]); - __pyx_t_5 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_4; - __pyx_v_n_cols = __pyx_t_5; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":104 + /* "Orange/distance/_distance.pyx":72 * - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< * with nogil: - * for col1 in range(n_cols): + * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 104, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":105 - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":73 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ { #ifdef WITH_THREAD @@ -3535,361 +2935,247 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":106 - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":74 + * n_rows2 = x2.shape[0] * with nogil: - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * d = 0 + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): */ - __pyx_t_10 = __pyx_v_n_cols; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_col1 = __pyx_t_11; + __pyx_t_3 = __pyx_v_n_rows1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":107 + /* "Orange/distance/_distance.pyx":75 * with nogil: - * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): - */ - __pyx_t_12 = __pyx_v_col1; - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_col2 = __pyx_t_13; - - /* "Orange/distance/_distance.pyx":108 - * for col1 in range(n_cols): - * for col2 in range(col1): - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":109 - * for col2 in range(col1): - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * if npy_isnan(distances[row1, row2]): + * d = 0 */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_5 = __pyx_v_n_rows2; + } else { + __pyx_t_5 = __pyx_v_row1; + } + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":110 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if normalize: - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) + /* "Orange/distance/_distance.pyx":76 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col1; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row; - __pyx_t_20 = __pyx_v_col2; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; + __pyx_t_7 = __pyx_v_row1; + __pyx_t_8 = __pyx_v_row2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":111 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + /* "Orange/distance/_distance.pyx":77 + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] */ - __pyx_t_22 = (__pyx_v_normalize != 0); - if (__pyx_t_22) { + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":112 - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) # <<<<<<<<<<<<<< - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + /* "Orange/distance/_distance.pyx":78 + * if npy_isnan(distances[row1, row2]): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): */ - __pyx_t_23 = __pyx_v_col1; - __pyx_t_24 = __pyx_v_col1; - __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_23 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_24 * __pyx_v_vars.strides[0]) )))))); + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":113 - * if normalize: - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":79 + * d = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< * if npy_isnan(val1): * if npy_isnan(val2): */ - __pyx_t_25 = __pyx_v_col2; - __pyx_t_26 = __pyx_v_col2; - __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_25 * __pyx_v_means.strides[0]) )))) / sqrt((2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_26 * __pyx_v_vars.strides[0]) )))))); - - /* "Orange/distance/_distance.pyx":114 - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + __pyx_t_12 = __pyx_v_row1; + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row2; + __pyx_t_16 = __pyx_v_col; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":80 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += dist_missing2[col] */ - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":115 - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + /* "Orange/distance/_distance.pyx":81 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + * d += dist_missing2[col] * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":82 * if npy_isnan(val1): * if npy_isnan(val2): - * d += 1 # <<<<<<<<<<<<<< + * d += dist_missing2[col] # <<<<<<<<<<<<<< * else: - * d += val2 ** 2 + 0.5 + * d += (val2 - means[col]) ** 2 + vars[col] */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":115 - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + /* "Orange/distance/_distance.pyx":81 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + * d += dist_missing2[col] * else: */ goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":118 - * d += 1 + /* "Orange/distance/_distance.pyx":84 + * d += dist_missing2[col] * else: - * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< + * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< * elif npy_isnan(val2): - * d += val1 ** 2 + 0.5 + * d += (val1 - means[col]) ** 2 + vars[col] */ /*else*/ { - __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val2, 2.0) + 0.5)); + __pyx_t_19 = __pyx_v_col; + __pyx_t_20 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_means.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_means.diminfo[0].strides))), 2.0) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_vars.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_vars.diminfo[0].strides)))); } __pyx_L14:; - /* "Orange/distance/_distance.pyx":114 - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + /* "Orange/distance/_distance.pyx":80 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += dist_missing2[col] */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":85 * else: - * d += val2 ** 2 + 0.5 + * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 ** 2 + 0.5 + * d += (val1 - means[col]) ** 2 + vars[col] * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":120 - * d += val2 ** 2 + 0.5 + /* "Orange/distance/_distance.pyx":86 + * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): - * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< + * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< * else: * d += (val1 - val2) ** 2 */ - __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); + __pyx_t_21 = __pyx_v_col; + __pyx_t_22 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_means.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_means.diminfo[0].strides))), 2.0) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_vars.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_vars.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":85 * else: - * d += val2 ** 2 + 0.5 + * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 ** 2 + 0.5 + * d += (val1 - means[col]) ** 2 + vars[col] * else: */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":122 - * d += val1 ** 2 + 0.5 + /* "Orange/distance/_distance.pyx":88 + * d += (val1 - means[col]) ** 2 + vars[col] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): + * distances[row1, row2] = d + * if not two_tables: */ /*else*/ { __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); } __pyx_L13:; - - /* "Orange/distance/_distance.pyx":111 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - * val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) - */ - goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":124 + /* "Orange/distance/_distance.pyx":89 + * else: * d += (val1 - val2) ** 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += vars[col1] + vars[col2] \ - */ - /*else*/ { - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":125 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += vars[col1] + vars[col2] \ - * + (means[col1] - means[col2]) ** 2 - */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":126 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< - * + (means[col1] - means[col2]) ** 2 - * else: - */ - __pyx_t_27 = __pyx_v_col1; - __pyx_t_28 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":127 - * if npy_isnan(val2): - * d += vars[col1] + vars[col2] \ - * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< - * else: - * d += (val2 - means[col1]) ** 2 + vars[col1] - */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":126 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< - * + (means[col1] - means[col2]) ** 2 - * else: - */ - __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_27 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_28 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_29 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))), 2.0))); - - /* "Orange/distance/_distance.pyx":125 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += vars[col1] + vars[col2] \ - * + (means[col1] - means[col2]) ** 2 - */ - goto __pyx_L16; - } - - /* "Orange/distance/_distance.pyx":129 - * + (means[col1] - means[col2]) ** 2 - * else: - * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += (val1 - means[col2]) ** 2 + vars[col2] + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if not two_tables: + * distances[row2, row1] = d */ - /*else*/ { - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_32 * __pyx_v_vars.strides[0]) ))))); - } - __pyx_L16:; + __pyx_t_23 = __pyx_v_row1; + __pyx_t_24 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":124 + /* "Orange/distance/_distance.pyx":90 * d += (val1 - val2) ** 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += vars[col1] + vars[col2] \ + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * distances[row2, row1] = d + * */ - goto __pyx_L15; - } + __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":130 - * else: - * d += (val2 - means[col1]) ** 2 + vars[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col2]) ** 2 + vars[col2] - * else: + /* "Orange/distance/_distance.pyx":91 + * distances[row1, row2] = d + * if not two_tables: + * distances[row2, row1] = d # <<<<<<<<<<<<<< + * + * */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_25 = __pyx_v_row2; + __pyx_t_26 = __pyx_v_row1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":131 - * d += (val2 - means[col1]) ** 2 + vars[col1] - * elif npy_isnan(val2): - * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< - * else: + /* "Orange/distance/_distance.pyx":90 * d += (val1 - val2) ** 2 + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * distances[row2, row1] = d + * */ - __pyx_t_33 = __pyx_v_col2; - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_34 * __pyx_v_vars.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":130 - * else: - * d += (val2 - means[col1]) ** 2 + vars[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += (val1 - means[col2]) ** 2 + vars[col2] - * else: - */ - goto __pyx_L15; - } - - /* "Orange/distance/_distance.pyx":133 - * d += (val1 - means[col2]) ** 2 + vars[col2] - * else: - * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d - * return np.sqrt(distances) - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); - } - __pyx_L15:; } - __pyx_L12:; - } - /* "Orange/distance/_distance.pyx":134 - * else: - * d += (val1 - val2) ** 2 - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return np.sqrt(distances) - * + /* "Orange/distance/_distance.pyx":76 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - __pyx_t_37 = __pyx_v_col2; - __pyx_t_38 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } } } } - /* "Orange/distance/_distance.pyx":105 - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":73 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ /*finally:*/ { /*normal exit:*/{ @@ -3902,115 +3188,78 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":135 - * d += (val1 - val2) ** 2 - * distances[col1, col2] = distances[col2, col1] = d - * return np.sqrt(distances) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - __pyx_t_39 = PyTuple_New(1+1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_39); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_39, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_39, 0+1, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":93 + /* "Orange/distance/_distance.pyx":59 * * - * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] means = fit_params["means"] + * def fix_euclidean_rows( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __Pyx_XDECREF(__pyx_t_39); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vars.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vars.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":138 +/* "Orange/distance/_distance.pyx":94 * * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows = {"manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4manhattan_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized = {"fix_euclidean_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_means = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_vars = 0; + PyArrayObject *__pyx_v_dist_missing2 = 0; char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("manhattan_rows (wrapper)", 0); + __Pyx_RefNannySetupContext("fix_euclidean_rows_normalized (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; - PyObject* values[4] = {0,0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_means,&__pyx_n_s_vars,&__pyx_n_s_dist_missing2,&__pyx_n_s_two_tables,0}; + PyObject* values[7] = {0,0,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 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); @@ -4021,51 +3270,76 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 1); __PYX_ERR(0, 94, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 2); __PYX_ERR(0, 94, __pyx_L3_error) } case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 3); __PYX_ERR(0, 94, __pyx_L3_error) + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 4); __PYX_ERR(0, 94, __pyx_L3_error) + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 5); __PYX_ERR(0, 94, __pyx_L3_error) + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 6); __PYX_ERR(0, 94, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 138, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows_normalized") < 0)) __PYX_ERR(0, 94, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { 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); - } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L3_error) - __pyx_v_fit_params = values[3]; + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + } + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x1 = ((PyArrayObject *)values[1]); + __pyx_v_x2 = ((PyArrayObject *)values[2]); + __pyx_v_means = ((PyArrayObject *)values[3]); + __pyx_v_vars = ((PyArrayObject *)values[4]); + __pyx_v_dist_missing2 = ((PyArrayObject *)values[5]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 138, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 94, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 138, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 139, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 95, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 96, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 97, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 98, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 99, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -4076,12 +3350,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5manhattan_rows(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -4091,61 +3360,47 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN double __pyx_v_val1; double __pyx_v_val2; double __pyx_v_d; - int __pyx_v_ival1; - int __pyx_v_ival2; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dist_missing2; + __Pyx_Buffer __pyx_pybuffer_dist_missing2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; + __Pyx_LocalBuf_ND __pyx_pybuffernd_means; + __Pyx_Buffer __pyx_pybuffer_means; + __Pyx_LocalBuf_ND __pyx_pybuffernd_vars; + __Pyx_Buffer __pyx_pybuffer_vars; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_4; - npy_intp __pyx_t_5; - npy_intp __pyx_t_6; - int __pyx_t_7; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - Py_ssize_t __pyx_t_10; - Py_ssize_t __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - int __pyx_t_15; - int __pyx_t_16; - int __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; - __pyx_t_5numpy_float64_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - __pyx_t_5numpy_float64_t __pyx_t_27; - int __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - Py_ssize_t __pyx_t_39; - Py_ssize_t __pyx_t_40; - Py_ssize_t __pyx_t_41; - Py_ssize_t __pyx_t_42; - Py_ssize_t __pyx_t_43; - Py_ssize_t __pyx_t_44; - Py_ssize_t __pyx_t_45; - __Pyx_RefNannySetupContext("manhattan_rows", 0); + __Pyx_RefNannySetupContext("fix_euclidean_rows_normalized", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -4154,223 +3409,73 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN __pyx_pybuffer_x2.refcount = 0; __pyx_pybuffernd_x2.data = NULL; __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + __pyx_pybuffer_means.pybuffer.buf = NULL; + __pyx_pybuffer_means.refcount = 0; + __pyx_pybuffernd_means.data = NULL; + __pyx_pybuffernd_means.rcbuffer = &__pyx_pybuffer_means; + __pyx_pybuffer_vars.pybuffer.buf = NULL; + __pyx_pybuffer_vars.refcount = 0; + __pyx_pybuffernd_vars.data = NULL; + __pyx_pybuffernd_vars.rcbuffer = &__pyx_pybuffer_vars; + __pyx_pybuffer_dist_missing2.pybuffer.buf = NULL; + __pyx_pybuffer_dist_missing2.refcount = 0; + __pyx_pybuffernd_dist_missing2.data = NULL; + __pyx_pybuffernd_dist_missing2.rcbuffer = &__pyx_pybuffer_dist_missing2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + } + __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + } + __pyx_pybuffernd_vars.diminfo[0].strides = __pyx_pybuffernd_vars.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vars.diminfo[0].shape = __pyx_pybuffernd_vars.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + } + __pyx_pybuffernd_dist_missing2.diminfo[0].strides = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2.diminfo[0].shape = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":143 - * fit_params): - * cdef: - * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_medians = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":144 - * cdef: - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_mads = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":145 - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; - - /* "Orange/distance/_distance.pyx":146 - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":147 - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_4; - - /* "Orange/distance/_distance.pyx":154 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":106 + * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * with nogil: */ - __pyx_t_5 = (__pyx_v_x1->dimensions[0]); - __pyx_t_6 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_5; - __pyx_v_n_cols = __pyx_t_6; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":155 + /* "Orange/distance/_distance.pyx":107 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ - * == len(dist_missing) == len(dist_missing2) + * with nogil: + * for row1 in range(n_rows1): */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":156 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":157 - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ - * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); - } - } - } - } - - /* "Orange/distance/_distance.pyx":156 + /* "Orange/distance/_distance.pyx":108 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * - */ - if (unlikely(!(__pyx_t_7 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 156, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":159 - * == len(dist_missing) == len(dist_missing2) - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * with nogil: - * for row1 in range(n_rows1): - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); - __pyx_t_1 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 159, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; - - /* "Orange/distance/_distance.pyx":160 - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -4382,570 +3487,323 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4manhattan_rows(CYTHON_UN #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":161 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) + /* "Orange/distance/_distance.pyx":109 + * n_rows2 = x2.shape[0] * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 + * if npy_isnan(distances[row1, row2]): */ - __pyx_t_15 = __pyx_v_n_rows1; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_row1 = __pyx_t_16; + __pyx_t_3 = __pyx_v_n_rows1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":162 + /* "Orange/distance/_distance.pyx":110 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): + * if npy_isnan(distances[row1, row2]): + * d = 0 */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_17 = __pyx_v_n_rows2; + __pyx_t_5 = __pyx_v_n_rows2; } else { - __pyx_t_17 = __pyx_v_row1; + __pyx_t_5 = __pyx_v_row1; } - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { - __pyx_v_row2 = __pyx_t_18; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":163 + /* "Orange/distance/_distance.pyx":111 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if mads[col] == -2: + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_v_d = 0.0; + __pyx_t_7 = __pyx_v_row1; + __pyx_t_8 = __pyx_v_row2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":164 + /* "Orange/distance/_distance.pyx":112 * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if mads[col] == -2: - * continue + * if npy_isnan(distances[row1, row2]): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] */ - __pyx_t_19 = __pyx_v_n_cols; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col = __pyx_t_20; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":165 - * d = 0 - * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue - * + /* "Orange/distance/_distance.pyx":113 + * if npy_isnan(distances[row1, row2]): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): */ - __pyx_t_21 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_7) { + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":166 - * for col in range(n_cols): - * if mads[col] == -2: - * continue # <<<<<<<<<<<<<< - * - * val1, val2 = x1[row1, col], x2[row2, col] + /* "Orange/distance/_distance.pyx":114 + * d = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - goto __pyx_L10_continue; - - /* "Orange/distance/_distance.pyx":165 - * d = 0 - * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue - * + __pyx_t_12 = __pyx_v_row1; + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row2; + __pyx_t_16 = __pyx_v_col; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":115 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += dist_missing2[col] */ - } + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":168 - * continue - * - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] + /* "Orange/distance/_distance.pyx":116 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * else: */ - __pyx_t_22 = __pyx_v_row1; - __pyx_t_23 = __pyx_v_col; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_25 = __pyx_v_row2; - __pyx_t_26 = __pyx_v_col; - __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_24; - __pyx_v_val2 = __pyx_t_27; - - /* "Orange/distance/_distance.pyx":169 - * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: - */ - __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_7 = __pyx_t_28; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_7 = __pyx_t_28; - __pyx_L14_bool_binop_done:; - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":170 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - */ - __pyx_t_29 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - - /* "Orange/distance/_distance.pyx":169 - * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: - */ - goto __pyx_L13; - } + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":171 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) + /* "Orange/distance/_distance.pyx":117 * if npy_isnan(val1): + * if npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * else: + * d += val2 ** 2 + 0.5 */ - __pyx_t_30 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_7) { + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":172 - * d += dist_missing2[col] - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":116 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): - * d += dist_missing[col, ival2] - */ - __pyx_v_ival1 = ((int)__pyx_v_val1); - __pyx_v_ival2 = ((int)__pyx_v_val2); - - /* "Orange/distance/_distance.pyx":173 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * else: */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":174 - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":119 + * d += dist_missing2[col] + * else: + * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< * elif npy_isnan(val2): - * d += dist_missing[col, ival1] + * d += val1 ** 2 + 0.5 */ - __pyx_t_31 = __pyx_v_col; - __pyx_t_32 = __pyx_v_ival2; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); + /*else*/ { + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val2, 2.0) + 0.5)); + } + __pyx_L14:; - /* "Orange/distance/_distance.pyx":173 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) + /* "Orange/distance/_distance.pyx":115 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): + * if npy_isnan(val2): + * d += dist_missing2[col] */ - goto __pyx_L16; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":175 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] + /* "Orange/distance/_distance.pyx":120 + * else: + * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + * d += val1 ** 2 + 0.5 + * else: */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":176 - * d += dist_missing[col, ival2] + /* "Orange/distance/_distance.pyx":121 + * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): - * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< - * elif ival1 != ival2: - * d += 1 + * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += (val1 - val2) ** 2 */ - __pyx_t_33 = __pyx_v_col; - __pyx_t_34 = __pyx_v_ival1; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":175 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] + /* "Orange/distance/_distance.pyx":120 + * else: + * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: + * d += val1 ** 2 + 0.5 + * else: */ - goto __pyx_L16; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":177 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: - */ - __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":178 - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - * d += 1 # <<<<<<<<<<<<<< - * elif normalize: - * if npy_isnan(val1): - */ - __pyx_v_d = (__pyx_v_d + 1.0); - - /* "Orange/distance/_distance.pyx":177 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: + /* "Orange/distance/_distance.pyx":123 + * d += val1 ** 2 + 0.5 + * else: + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * if not two_tables: */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); } - __pyx_L16:; - - /* "Orange/distance/_distance.pyx":171 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - */ - goto __pyx_L13; + __pyx_L13:; } - /* "Orange/distance/_distance.pyx":179 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":124 + * else: + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if not two_tables: + * distances[row2, row1] = d */ - __pyx_t_7 = (__pyx_v_normalize != 0); - if (__pyx_t_7) { + __pyx_t_19 = __pyx_v_row1; + __pyx_t_20 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":180 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":125 + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * distances[row2, row1] = d + * */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":181 - * elif normalize: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + /* "Orange/distance/_distance.pyx":126 + * distances[row1, row2] = d + * if not two_tables: + * distances[row2, row1] = d # <<<<<<<<<<<<<< + * + * */ - __pyx_t_35 = __pyx_v_col; - __pyx_t_36 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + __pyx_t_21 = __pyx_v_row2; + __pyx_t_22 = __pyx_v_row1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":180 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":125 + * d += (val1 - val2) ** 2 + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * distances[row2, row1] = d + * */ - goto __pyx_L17; - } + } - /* "Orange/distance/_distance.pyx":182 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: + /* "Orange/distance/_distance.pyx":111 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { + } + } + } + } - /* "Orange/distance/_distance.pyx":183 - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) / mads[col] / 2 + /* "Orange/distance/_distance.pyx":108 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_37 = __pyx_v_col; - __pyx_t_38 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } - /* "Orange/distance/_distance.pyx":182 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: - */ - goto __pyx_L17; - } - - /* "Orange/distance/_distance.pyx":185 - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: - * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): - */ - /*else*/ { - __pyx_t_39 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); - } - __pyx_L17:; - - /* "Orange/distance/_distance.pyx":179 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":187 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - */ - /*else*/ { - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":188 - * else: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] - */ - __pyx_t_40 = __pyx_v_col; - __pyx_t_41 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":187 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":189 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":190 - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) - */ - __pyx_t_42 = __pyx_v_col; - __pyx_t_43 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":189 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":192 - * d += fabs(val1 - medians[col]) + mads[col] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * - * distances[row1, row2] = d - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); - } - __pyx_L18:; - } - __pyx_L13:; - __pyx_L10_continue:; - } - - /* "Orange/distance/_distance.pyx":194 - * d += fabs(val1 - val2) - * - * distances[row1, row2] = d # <<<<<<<<<<<<<< - * - * if not two_tables: - */ - __pyx_t_44 = __pyx_v_row1; - __pyx_t_45 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } - } - } - - /* "Orange/distance/_distance.pyx":160 - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * with nogil: # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "Orange/distance/_distance.pyx":196 - * distances[row1, row2] = d - * - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":197 - * - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - - /* "Orange/distance/_distance.pyx":196 - * distances[row1, row2] = d - * - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":198 - * if not two_tables: - * _lower_to_symmetric(distances) - * return distances # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":138 - * - * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "Orange/distance/_distance.pyx":94 + * + * + * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vars.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vars.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":201 +/* "Orange/distance/_distance.pyx":129 * * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_euclidean_cols( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_6manhattan_cols[] = "manhattan_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_6manhattan_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_cols[] = "fix_euclidean_cols(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_cols = {"fix_euclidean_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("manhattan_cols (wrapper)", 0); + __Pyx_RefNannySetupContext("fix_euclidean_cols (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x,&__pyx_n_s_means,&__pyx_n_s_vars,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -4954,36 +3812,51 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 1); __PYX_ERR(0, 129, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 2); __PYX_ERR(0, 129, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 201, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 3); __PYX_ERR(0, 129, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 201, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols") < 0)) __PYX_ERR(0, 129, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x = ((PyArrayObject *)values[1]); + __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 132, __pyx_L3_error) + __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 133, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 129, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 201, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 130, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); /* function exit code */ goto __pyx_L0; @@ -4994,10 +3867,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7manhattan_cols(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -5006,33 +3876,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN double __pyx_v_val1; double __pyx_v_val2; double __pyx_v_d; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_3; - npy_intp __pyx_t_4; - npy_intp __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; - int __pyx_t_13; - int __pyx_t_14; - int __pyx_t_15; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - __pyx_t_5numpy_float64_t __pyx_t_18; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; Py_ssize_t __pyx_t_20; - __pyx_t_5numpy_float64_t __pyx_t_21; - int __pyx_t_22; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; Py_ssize_t __pyx_t_24; Py_ssize_t __pyx_t_25; @@ -5040,130 +3911,41 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN Py_ssize_t __pyx_t_27; Py_ssize_t __pyx_t_28; Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - __Pyx_RefNannySetupContext("manhattan_cols", 0); + __Pyx_RefNannySetupContext("fix_euclidean_cols", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 201, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 129, __pyx_L1_error) + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 129, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":203 - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< - * double [:] mads = fit_params["mads"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_medians = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":204 - * cdef: - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_mads = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":205 - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, col1, col2, row - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_3; - - /* "Orange/distance/_distance.pyx":211 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":138 + * double val1, val2, d * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) - * with nogil: - */ - __pyx_t_4 = (__pyx_v_x->dimensions[0]); - __pyx_t_5 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_4; - __pyx_v_n_cols = __pyx_t_5; - - /* "Orange/distance/_distance.pyx":212 - * - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 212, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 212, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + __pyx_t_1 = (__pyx_v_x->dimensions[0]); + __pyx_t_2 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":139 + * * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): @@ -5175,358 +3957,232 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":214 - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":140 + * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< * for col2 in range(col1): - * d = 0 + * if npy_isnan(distances[col1, col2]): */ - __pyx_t_10 = __pyx_v_n_cols; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_col1 = __pyx_t_11; + __pyx_t_3 = __pyx_v_n_cols; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_col1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":215 + /* "Orange/distance/_distance.pyx":141 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): + * if npy_isnan(distances[col1, col2]): + * d = 0 */ - __pyx_t_12 = __pyx_v_col1; - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_col2 = __pyx_t_13; + __pyx_t_5 = __pyx_v_col1; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_col2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":216 + /* "Orange/distance/_distance.pyx":142 * for col1 in range(n_cols): * for col2 in range(col1): - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - __pyx_v_d = 0.0; + __pyx_t_7 = __pyx_v_col1; + __pyx_t_8 = __pyx_v_col2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":217 + /* "Orange/distance/_distance.pyx":143 * for col2 in range(col1): - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: - */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; - - /* "Orange/distance/_distance.pyx":218 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col1; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row; - __pyx_t_20 = __pyx_v_col2; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; - - /* "Orange/distance/_distance.pyx":219 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(distances[col1, col2]): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_t_22 = (__pyx_v_normalize != 0); - if (__pyx_t_22) { + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":220 - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":144 + * if npy_isnan(distances[col1, col2]): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): */ - __pyx_t_23 = __pyx_v_col1; - __pyx_t_24 = __pyx_v_col1; - __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); + __pyx_t_10 = __pyx_v_n_rows; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_row = __pyx_t_11; - /* "Orange/distance/_distance.pyx":221 - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":145 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< * if npy_isnan(val1): * if npy_isnan(val2): */ - __pyx_t_25 = __pyx_v_col2; - __pyx_t_26 = __pyx_v_col2; - __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":222 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + __pyx_t_12 = __pyx_v_row; + __pyx_t_13 = __pyx_v_col1; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col2; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":146 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += vars[col1] + vars[col2] \ */ - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":223 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":147 + * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 + */ + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { + + /* "Orange/distance/_distance.pyx":148 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< + * + (means[col1] - means[col2]) ** 2 * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_18 = __pyx_v_col1; + __pyx_t_19 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":149 + * if npy_isnan(val2): + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< + * else: + * d += (val2 - means[col1]) ** 2 + vars[col1] + */ + __pyx_t_20 = __pyx_v_col1; + __pyx_t_21 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":224 + /* "Orange/distance/_distance.pyx":148 * if npy_isnan(val1): * if npy_isnan(val2): - * d += 1 # <<<<<<<<<<<<<< + * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< + * + (means[col1] - means[col2]) ** 2 * else: - * d += fabs(val2) + 0.5 */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_20 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_21 * __pyx_v_means.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":223 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":147 + * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 - * else: + * d += vars[col1] + vars[col2] \ + * + (means[col1] - means[col2]) ** 2 */ goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":226 - * d += 1 + /* "Orange/distance/_distance.pyx":151 + * + (means[col1] - means[col2]) ** 2 * else: - * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 + * d += (val1 - means[col2]) ** 2 + vars[col2] */ /*else*/ { - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + __pyx_t_22 = __pyx_v_col1; + __pyx_t_23 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_22 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_23 * __pyx_v_vars.strides[0]) ))))); } __pyx_L14:; - /* "Orange/distance/_distance.pyx":222 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":146 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += vars[col1] + vars[col2] \ */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":227 + /* "Orange/distance/_distance.pyx":152 * else: - * d += fabs(val2) + 0.5 + * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + * d += (val1 - means[col2]) ** 2 + vars[col2] * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":228 - * d += fabs(val2) + 0.5 + /* "Orange/distance/_distance.pyx":153 + * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< + * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< * else: - * d += fabs(val1 - val2) + * d += (val1 - val2) ** 2 */ - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); + __pyx_t_24 = __pyx_v_col2; + __pyx_t_25 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_24 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_25 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":227 + /* "Orange/distance/_distance.pyx":152 * else: - * d += fabs(val2) + 0.5 + * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + * d += (val1 - means[col2]) ** 2 + vars[col2] * else: */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":230 - * d += fabs(val1) + 0.5 + /* "Orange/distance/_distance.pyx":155 + * d += (val1 - means[col2]) ** 2 + vars[col2] * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * */ /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); } __pyx_L13:; + } - /* "Orange/distance/_distance.pyx":219 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":156 + * else: + * d += (val1 - val2) ** 2 + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * + * */ - goto __pyx_L12; - } + __pyx_t_26 = __pyx_v_col1; + __pyx_t_27 = __pyx_v_col2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; + __pyx_t_28 = __pyx_v_col2; + __pyx_t_29 = __pyx_v_col1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":232 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - */ - /*else*/ { - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":233 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) - */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":234 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: - */ - __pyx_t_27 = __pyx_v_col1; - __pyx_t_28 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":235 - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":234 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: - */ - __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); - - /* "Orange/distance/_distance.pyx":233 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) - */ - goto __pyx_L16; - } - - /* "Orange/distance/_distance.pyx":237 - * + fabs(medians[col1] - medians[col2]) - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] - */ - /*else*/ { - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); - } - __pyx_L16:; - - /* "Orange/distance/_distance.pyx":232 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - */ - goto __pyx_L15; - } - - /* "Orange/distance/_distance.pyx":238 - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":239 - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) - */ - __pyx_t_33 = __pyx_v_col2; - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":238 - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - */ - goto __pyx_L15; - } - - /* "Orange/distance/_distance.pyx":241 - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d - * return distances + /* "Orange/distance/_distance.pyx":142 + * for col1 in range(n_cols): + * for col2 in range(col1): + * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); - } - __pyx_L15:; - } - __pyx_L12:; } - - /* "Orange/distance/_distance.pyx":242 - * else: - * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - __pyx_t_37 = __pyx_v_col2; - __pyx_t_38 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } } } - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":139 + * * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for col1 in range(n_cols): * for col2 in range(col1): @@ -5542,74 +4198,121 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6manhattan_cols(CYTHON_UN } } - /* "Orange/distance/_distance.pyx":243 - * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d - * return distances # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":201 + /* "Orange/distance/_distance.pyx":129 * * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_euclidean_cols( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":246 +/* "Orange/distance/_distance.pyx":159 * * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_8p_nonzero[] = "p_nonzero(ndarray x)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_8p_nonzero}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized = {"fix_euclidean_cols_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; + PyArrayObject *__pyx_v_x = 0; + CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 246, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); + __Pyx_RefNannySetupContext("fix_euclidean_cols_normalized (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x,&__pyx_n_s_means,&__pyx_n_s_vars,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 1); __PYX_ERR(0, 159, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 2); __PYX_ERR(0, 159, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 3); __PYX_ERR(0, 159, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols_normalized") < 0)) __PYX_ERR(0, 159, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + 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); + } + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x = ((PyArrayObject *)values[1]); + __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 162, __pyx_L3_error) + __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 163, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 159, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 160, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); /* function exit code */ goto __pyx_L0; @@ -5620,1567 +4323,1521 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9p_nonzero(PyObject *__py return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars) { + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_col1; + int __pyx_v_col2; int __pyx_v_row; - int __pyx_v_nonzeros; - int __pyx_v_nonnans; - double __pyx_v_val; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("p_nonzero", 0); + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + Py_ssize_t __pyx_t_21; + __Pyx_RefNannySetupContext("fix_euclidean_cols_normalized", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 159, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 159, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":251 - * double val + /* "Orange/distance/_distance.pyx":168 + * double val1, val2, d * - * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< - * for row in range(len(x)): - * val = x[row] + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * with nogil: + * for col1 in range(n_cols): */ - __pyx_v_nonzeros = 0; - __pyx_v_nonnans = 0; + __pyx_t_1 = (__pyx_v_x->dimensions[0]); + __pyx_t_2 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":252 + /* "Orange/distance/_distance.pyx":169 * - * nonzeros = nonnans = 0 - * for row in range(len(x)): # <<<<<<<<<<<<<< - * val = x[row] - * if not npy_isnan(val): + * n_rows, n_cols = x.shape[0], x.shape[1] + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 252, __pyx_L1_error) - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_row = __pyx_t_2; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":253 - * nonzeros = nonnans = 0 - * for row in range(len(x)): - * val = x[row] # <<<<<<<<<<<<<< - * if not npy_isnan(val): - * nonnans += 1 + /* "Orange/distance/_distance.pyx":170 + * n_rows, n_cols = x.shape[0], x.shape[1] + * with nogil: + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * if npy_isnan(distances[col1, col2]): */ - __pyx_t_3 = __pyx_v_row; - __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); + __pyx_t_3 = __pyx_v_n_cols; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_col1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":254 - * for row in range(len(x)): - * val = x[row] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: + /* "Orange/distance/_distance.pyx":171 + * with nogil: + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * if npy_isnan(distances[col1, col2]): + * d = 0 */ - __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); - if (__pyx_t_4) { + __pyx_t_5 = __pyx_v_col1; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_col2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":255 - * val = x[row] - * if not npy_isnan(val): - * nonnans += 1 # <<<<<<<<<<<<<< - * if val != 0: - * nonzeros += 1 + /* "Orange/distance/_distance.pyx":172 + * for col1 in range(n_cols): + * for col2 in range(col1): + * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - __pyx_v_nonnans = (__pyx_v_nonnans + 1); + __pyx_t_7 = __pyx_v_col1; + __pyx_t_8 = __pyx_v_col2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":256 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * return float(nonzeros) / nonnans + /* "Orange/distance/_distance.pyx":173 + * for col2 in range(col1): + * if npy_isnan(distances[col1, col2]): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); - if (__pyx_t_4) { + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":257 - * nonnans += 1 - * if val != 0: - * nonzeros += 1 # <<<<<<<<<<<<<< - * return float(nonzeros) / nonnans - * + /* "Orange/distance/_distance.pyx":174 + * if npy_isnan(distances[col1, col2]): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): */ - __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); + __pyx_t_10 = __pyx_v_n_rows; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_row = __pyx_t_11; - /* "Orange/distance/_distance.pyx":256 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * return float(nonzeros) / nonnans + /* "Orange/distance/_distance.pyx":175 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - } + __pyx_t_12 = __pyx_v_row; + __pyx_t_13 = __pyx_v_col1; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col2; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; + + /* "Orange/distance/_distance.pyx":176 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":254 - * for row in range(len(x)): - * val = x[row] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: + /* "Orange/distance/_distance.pyx":177 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: */ - } - } + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":258 - * if val != 0: - * nonzeros += 1 - * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":178 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += val2 ** 2 + 0.5 + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":177 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":180 + * d += 1 + * else: + * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 ** 2 + 0.5 + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val2, 2.0) + 0.5)); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":176 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":181 + * else: + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 ** 2 + 0.5 + * else: + */ + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { + + /* "Orange/distance/_distance.pyx":182 + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): + * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += (val1 - val2) ** 2 + */ + __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); + + /* "Orange/distance/_distance.pyx":181 + * else: + * d += val2 ** 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 ** 2 + 0.5 + * else: + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":184 + * d += val1 ** 2 + 0.5 + * else: + * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow((__pyx_v_val1 - __pyx_v_val2), 2.0)); + } + __pyx_L13:; + } + + /* "Orange/distance/_distance.pyx":185 + * else: + * d += (val1 - val2) ** 2 + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< * * */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; + __pyx_t_18 = __pyx_v_col1; + __pyx_t_19 = __pyx_v_col2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = __pyx_v_col1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":246 + /* "Orange/distance/_distance.pyx":172 + * for col1 in range(n_cols): + * for col2 in range(col1): + * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): + */ + } + } + } + } + + /* "Orange/distance/_distance.pyx":169 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "Orange/distance/_distance.pyx":159 * * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.p_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":261 +/* "Orange/distance/_distance.pyx":188 * * - * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - double __pyx_v_d; - double __pyx_v_val; - int __pyx_v_row; - int __pyx_v_col; - int __pyx_v_n_rows; - int __pyx_v_n_cols; - PyObject *__pyx_r = NULL; +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows = {"manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - int __pyx_t_12; - Py_ssize_t __pyx_t_13; - int __pyx_t_14; - Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - Py_ssize_t __pyx_t_18; - Py_ssize_t __pyx_t_19; - Py_ssize_t __pyx_t_20; - Py_ssize_t __pyx_t_21; - __Pyx_RefNannySetupContext("_abs_rows", 0); + __Pyx_RefNannySetupContext("manhattan_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 188, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 188, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 188, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 188, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + 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); + } + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) + __pyx_v_fit_params = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 188, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 189, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); - /* "Orange/distance/_distance.pyx":267 - * int row, col, n_rows, n_cols - * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * abss = np.empty(n_rows) - * with nogil: - */ - __pyx_t_1 = (__pyx_v_x.shape[0]); - __pyx_t_2 = (__pyx_v_x.shape[1]); - __pyx_v_n_rows = __pyx_t_1; - __pyx_v_n_cols = __pyx_t_2; + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":268 - * - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) # <<<<<<<<<<<<<< - * with nogil: - * for row in range(n_rows): - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + int __pyx_v_ival1; + int __pyx_v_ival2; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_4; + npy_intp __pyx_t_5; + npy_intp __pyx_t_6; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + Py_ssize_t __pyx_t_9; + Py_ssize_t __pyx_t_10; + Py_ssize_t __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + __pyx_t_5numpy_float64_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + __pyx_t_5numpy_float64_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + Py_ssize_t __pyx_t_42; + Py_ssize_t __pyx_t_43; + Py_ssize_t __pyx_t_44; + Py_ssize_t __pyx_t_45; + __Pyx_RefNannySetupContext("manhattan_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) } - if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_abss = __pyx_t_8; - __pyx_t_8.memview = NULL; - __pyx_t_8.data = NULL; + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":269 - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) - * with nogil: # <<<<<<<<<<<<<< - * for row in range(n_rows): - * d = 0 + /* "Orange/distance/_distance.pyx":193 + * fit_params): + * cdef: + * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_medians = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":270 - * abss = np.empty(n_rows) - * with nogil: - * for row in range(n_rows): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): + /* "Orange/distance/_distance.pyx":194 + * cdef: + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] */ - __pyx_t_9 = __pyx_v_n_rows; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_row = __pyx_t_10; + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_mads = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":271 - * with nogil: - * for row in range(n_rows): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":272 - * for row in range(n_rows): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * continue + /* "Orange/distance/_distance.pyx":195 + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] */ - __pyx_t_11 = __pyx_v_n_cols; - for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { - __pyx_v_col = __pyx_t_12; + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":273 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val = x[row, col] + /* "Orange/distance/_distance.pyx":196 + * double [:] mads = fit_params["mads"] + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * */ - __pyx_t_13 = __pyx_v_col; - __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_14) { + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_dist_missing2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":274 - * for col in range(n_cols): - * if vars[col] == -2: - * continue # <<<<<<<<<<<<<< - * val = x[row, col] - * if vars[col] == -1: + /* "Orange/distance/_distance.pyx":197 + * double [:, :] dist_missing = fit_params["dist_missing"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col */ - goto __pyx_L8_continue; + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_4; - /* "Orange/distance/_distance.pyx":273 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val = x[row, col] + /* "Orange/distance/_distance.pyx":204 + * double [:, :] distances + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ */ - } + __pyx_t_5 = (__pyx_v_x1->dimensions[0]); + __pyx_t_6 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_5; + __pyx_v_n_cols = __pyx_t_6; - /* "Orange/distance/_distance.pyx":275 - * if vars[col] == -2: - * continue - * val = x[row, col] # <<<<<<<<<<<<<< - * if vars[col] == -1: - * if npy_isnan(val): + /* "Orange/distance/_distance.pyx":205 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * == len(dist_missing) == len(dist_missing2) */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col; - __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":276 - * continue - * val = x[row, col] - * if vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val): - * d += means[col] + /* "Orange/distance/_distance.pyx":206 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * */ - __pyx_t_17 = __pyx_v_col; - __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_14) { + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":277 - * val = x[row, col] - * if vars[col] == -1: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] - * elif val != 0: + /* "Orange/distance/_distance.pyx":207 + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_14) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); + if (__pyx_t_7) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); + } + } + } + } - /* "Orange/distance/_distance.pyx":278 - * if vars[col] == -1: - * if npy_isnan(val): - * d += means[col] # <<<<<<<<<<<<<< - * elif val != 0: - * d += 1 + /* "Orange/distance/_distance.pyx":206 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< + * == len(dist_missing) == len(dist_missing2) + * */ - __pyx_t_18 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); + if (unlikely(!(__pyx_t_7 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 206, __pyx_L1_error) + } + } + #endif - /* "Orange/distance/_distance.pyx":277 - * val = x[row, col] - * if vars[col] == -1: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] - * elif val != 0: + /* "Orange/distance/_distance.pyx":209 + * == len(dist_missing) == len(dist_missing2) + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * with nogil: + * for row1 in range(n_rows1): */ - goto __pyx_L12; - } + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); + __pyx_t_14 = 0; + __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 209, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_3; + __pyx_t_3.memview = NULL; + __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":279 - * if npy_isnan(val): - * d += means[col] - * elif val != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":210 + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); - if (__pyx_t_14) { + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":280 - * d += means[col] - * elif val != 0: - * d += 1 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val): + /* "Orange/distance/_distance.pyx":211 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_t_15 = __pyx_v_n_rows1; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_row1 = __pyx_t_16; - /* "Orange/distance/_distance.pyx":279 - * if npy_isnan(val): - * d += means[col] - * elif val != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":212 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - } - __pyx_L12:; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_17 = __pyx_v_n_rows2; + } else { + __pyx_t_17 = __pyx_v_row1; + } + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { + __pyx_v_row2 = __pyx_t_18; - /* "Orange/distance/_distance.pyx":276 - * continue - * val = x[row, col] - * if vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val): - * d += means[col] + /* "Orange/distance/_distance.pyx":213 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if mads[col] == -2: */ - goto __pyx_L11; - } + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":282 - * d += 1 - * else: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] ** 2 + vars[col] - * else: + /* "Orange/distance/_distance.pyx":214 + * for row2 in range(n_rows2 if two_tables else row1): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if mads[col] == -2: + * continue */ - /*else*/ { - __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_14) { + __pyx_t_19 = __pyx_v_n_cols; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col = __pyx_t_20; - /* "Orange/distance/_distance.pyx":283 - * else: - * if npy_isnan(val): - * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< - * else: - * d += val ** 2 + /* "Orange/distance/_distance.pyx":215 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue + * */ - __pyx_t_19 = __pyx_v_col; - __pyx_t_20 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); + __pyx_t_21 = __pyx_v_col; + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":282 - * d += 1 - * else: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] ** 2 + vars[col] - * else: + /* "Orange/distance/_distance.pyx":216 + * for col in range(n_cols): + * if mads[col] == -2: + * continue # <<<<<<<<<<<<<< + * + * val1, val2 = x1[row1, col], x2[row2, col] */ - goto __pyx_L13; - } + goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":285 - * d += means[col] ** 2 + vars[col] - * else: - * d += val ** 2 # <<<<<<<<<<<<<< - * abss[row] = sqrt(d) - * return abss + /* "Orange/distance/_distance.pyx":215 + * d = 0 + * for col in range(n_cols): + * if mads[col] == -2: # <<<<<<<<<<<<<< + * continue + * */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); } - __pyx_L13:; - } - __pyx_L11:; - __pyx_L8_continue:; - } - /* "Orange/distance/_distance.pyx":286 - * else: - * d += val ** 2 - * abss[row] = sqrt(d) # <<<<<<<<<<<<<< - * return abss + /* "Orange/distance/_distance.pyx":218 + * continue * + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] */ - __pyx_t_21 = __pyx_v_row; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_21 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); - } - } + __pyx_t_22 = __pyx_v_row1; + __pyx_t_23 = __pyx_v_col; + __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_25 = __pyx_v_row2; + __pyx_t_26 = __pyx_v_col; + __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_24; + __pyx_v_val2 = __pyx_t_27; - /* "Orange/distance/_distance.pyx":269 - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) - * with nogil: # <<<<<<<<<<<<<< - * for row in range(n_rows): - * d = 0 + /* "Orange/distance/_distance.pyx":219 + * + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } + __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_7 = __pyx_t_28; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_7 = __pyx_t_28; + __pyx_L14_bool_binop_done:; + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":287 - * d += val ** 2 - * abss[row] = sqrt(d) - * return abss # <<<<<<<<<<<<<< - * - * + /* "Orange/distance/_distance.pyx":220 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + __pyx_t_29 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":261 - * + /* "Orange/distance/_distance.pyx":219 * - * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif mads[col] == -1: */ + goto __pyx_L13; + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_AddTraceback("Orange.distance._distance._abs_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "Orange/distance/_distance.pyx":221 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + */ + __pyx_t_30 = __pyx_v_col; + __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_7) { -/* "Orange/distance/_distance.pyx":290 - * - * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "Orange/distance/_distance.pyx":222 + * d += dist_missing2[col] + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += dist_missing[col, ival2] */ + __pyx_v_ival1 = ((int)__pyx_v_val1); + __pyx_v_ival2 = ((int)__pyx_v_val2); -/* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_10cosine_rows[] = "cosine_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11cosine_rows = {"cosine_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11cosine_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10cosine_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x1 = 0; - PyArrayObject *__pyx_v_x2 = 0; - char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cosine_rows (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; - PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 290, __pyx_L3_error) - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 290, __pyx_L3_error) - } - case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 290, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 290, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { - 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); - } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 292, __pyx_L3_error) - __pyx_v_fit_params = values[3]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 290, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 290, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 291, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + /* "Orange/distance/_distance.pyx":223 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + */ + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_v_n_rows1; - int __pyx_v_n_rows2; - int __pyx_v_n_cols; - int __pyx_v_row1; - int __pyx_v_row2; - int __pyx_v_col; - double __pyx_v_val1; - double __pyx_v_val2; - double __pyx_v_d; - __Pyx_memviewslice __pyx_v_abs1 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_abs2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; - __Pyx_Buffer __pyx_pybuffer_x1; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; - __Pyx_Buffer __pyx_pybuffer_x2; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; - int __pyx_t_5; - Py_ssize_t __pyx_t_6; - Py_ssize_t __pyx_t_7; - Py_ssize_t __pyx_t_8; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - int __pyx_t_14; - int __pyx_t_15; - int __pyx_t_16; - int __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - Py_ssize_t __pyx_t_20; - Py_ssize_t __pyx_t_21; - Py_ssize_t __pyx_t_22; - __pyx_t_5numpy_float64_t __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - __pyx_t_5numpy_float64_t __pyx_t_26; - int __pyx_t_27; - Py_ssize_t __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - __Pyx_RefNannySetupContext("cosine_rows", 0); - __pyx_pybuffer_x1.pybuffer.buf = NULL; - __pyx_pybuffer_x1.refcount = 0; - __pyx_pybuffernd_x1.data = NULL; - __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; - __pyx_pybuffer_x2.pybuffer.buf = NULL; - __pyx_pybuffer_x2.refcount = 0; - __pyx_pybuffernd_x2.data = NULL; - __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 290, __pyx_L1_error) - } - __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 290, __pyx_L1_error) - } - __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + /* "Orange/distance/_distance.pyx":224 + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): + * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + */ + __pyx_t_31 = __pyx_v_col; + __pyx_t_32 = __pyx_v_ival2; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":295 - * fit_params): - * cdef: - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * double [:] means = fit_params["means"] - * double [:] dist_missing2 = fit_params["dist_missing2"] + /* "Orange/distance/_distance.pyx":223 + * elif mads[col] == -1: + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":296 - * cdef: - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * double [:] dist_missing2 = fit_params["dist_missing2"] - * + /* "Orange/distance/_distance.pyx":225 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":297 - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] - * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col + /* "Orange/distance/_distance.pyx":226 + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< + * elif ival1 != ival2: + * d += 1 */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_t_33 = __pyx_v_col; + __pyx_t_34 = __pyx_v_ival1; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - /* "Orange/distance/_distance.pyx":304 - * double [:, :] distances - * - * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + /* "Orange/distance/_distance.pyx":225 + * if npy_isnan(val1): + * d += dist_missing[col, ival2] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing[col, ival1] + * elif ival1 != ival2: */ - __pyx_t_3 = (__pyx_v_x1->dimensions[0]); - __pyx_t_4 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":305 - * - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) + /* "Orange/distance/_distance.pyx":227 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: */ - __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); + __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":306 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) + /* "Orange/distance/_distance.pyx":228 + * d += dist_missing[col, ival1] + * elif ival1 != ival2: + * d += 1 # <<<<<<<<<<<<<< + * elif normalize: + * if npy_isnan(val1): */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); - if (__pyx_t_5) { + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":307 - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) # <<<<<<<<<<<<<< - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + /* "Orange/distance/_distance.pyx":227 + * elif npy_isnan(val2): + * d += dist_missing[col, ival1] + * elif ival1 != ival2: # <<<<<<<<<<<<<< + * d += 1 + * elif normalize: */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); - } - } - } + } + __pyx_L16:; - /* "Orange/distance/_distance.pyx":306 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) + /* "Orange/distance/_distance.pyx":221 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif mads[col] == -1: # <<<<<<<<<<<<<< + * ival1, ival2 = int(val1), int(val2) + * if npy_isnan(val1): */ - if (unlikely(!(__pyx_t_5 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 306, __pyx_L1_error) - } - } - #endif + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":308 - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) + /* "Orange/distance/_distance.pyx":229 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_abs1 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_t_7 = (__pyx_v_normalize != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":309 - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * + /* "Orange/distance/_distance.pyx":230 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): */ - if ((__pyx_v_two_tables != 0)) { - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __pyx_t_10; - __pyx_t_10.memview = NULL; - __pyx_t_10.data = NULL; - } else { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __pyx_t_10; - __pyx_t_10.memview = NULL; - __pyx_t_10.data = NULL; - } - __pyx_v_abs2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":310 - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * - * with nogil: + /* "Orange/distance/_distance.pyx":231 + * elif normalize: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); - __pyx_t_1 = 0; - __pyx_t_12 = 0; - __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); - __pyx_t_13 = 0; - __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 310, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + __pyx_t_35 = __pyx_v_col; + __pyx_t_36 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":312 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * - * with nogil: # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): + /* "Orange/distance/_distance.pyx":230 + * d += 1 + * elif normalize: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { + goto __pyx_L17; + } - /* "Orange/distance/_distance.pyx":313 - * - * with nogil: - * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 + /* "Orange/distance/_distance.pyx":232 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: */ - __pyx_t_14 = __pyx_v_n_rows1; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row1 = __pyx_t_15; + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":314 - * with nogil: - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): + /* "Orange/distance/_distance.pyx":233 + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) / mads[col] / 2 */ - if ((__pyx_v_two_tables != 0)) { - __pyx_t_16 = __pyx_v_n_rows2; - } else { - __pyx_t_16 = __pyx_v_row1; - } - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { - __pyx_v_row2 = __pyx_t_17; + __pyx_t_37 = __pyx_v_col; + __pyx_t_38 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":315 - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: + /* "Orange/distance/_distance.pyx":232 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: */ - __pyx_v_d = 0.0; + goto __pyx_L17; + } - /* "Orange/distance/_distance.pyx":316 - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * continue + /* "Orange/distance/_distance.pyx":235 + * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 + * else: + * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): */ - __pyx_t_18 = __pyx_v_n_cols; - for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { - __pyx_v_col = __pyx_t_19; + /*else*/ { + __pyx_t_39 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); + } + __pyx_L17:; - /* "Orange/distance/_distance.pyx":317 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val1, val2 = x1[row1, col], x2[row2, col] + /* "Orange/distance/_distance.pyx":229 + * elif ival1 != ival2: + * d += 1 + * elif normalize: # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 */ - __pyx_t_20 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_5) { + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":318 - * for col in range(n_cols): - * if vars[col] == -2: - * continue # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): + /* "Orange/distance/_distance.pyx":237 + * d += fabs(val1 - val2) / mads[col] / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): */ - goto __pyx_L10_continue; + /*else*/ { + __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":317 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val1, val2 = x1[row1, col], x2[row2, col] + /* "Orange/distance/_distance.pyx":238 + * else: + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] */ - } + __pyx_t_40 = __pyx_v_col; + __pyx_t_41 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":319 - * if vars[col] == -2: - * continue - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] + /* "Orange/distance/_distance.pyx":237 + * d += fabs(val1 - val2) / mads[col] / 2 + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): */ - __pyx_t_21 = __pyx_v_row1; - __pyx_t_22 = __pyx_v_col; - __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_24 = __pyx_v_row2; - __pyx_t_25 = __pyx_v_col; - __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_23; - __pyx_v_val2 = __pyx_t_26; + goto __pyx_L18; + } - /* "Orange/distance/_distance.pyx":320 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: + /* "Orange/distance/_distance.pyx":239 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: */ - __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L14_bool_binop_done:; - if (__pyx_t_5) { + __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":321 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ + /* "Orange/distance/_distance.pyx":240 + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) */ - __pyx_t_28 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); - - /* "Orange/distance/_distance.pyx":320 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":322 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: - */ - __pyx_t_29 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_5) { + __pyx_t_42 = __pyx_v_col; + __pyx_t_43 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":323 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] + /* "Orange/distance/_distance.pyx":239 + * if npy_isnan(val1): + * d += fabs(val2 - medians[col]) + mads[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] + * else: */ - __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); - if (!__pyx_t_27) { - goto __pyx_L18_next_or; - } else { - } - __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); - if (!__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L17_bool_binop_done; + goto __pyx_L18; } - __pyx_L18_next_or:; - /* "Orange/distance/_distance.pyx":324 - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< - * d += means[col] - * elif val1 != 0 and val2 != 0: + /* "Orange/distance/_distance.pyx":242 + * d += fabs(val1 - medians[col]) + mads[col] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * + * distances[row1, row2] = d */ - __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L17_bool_binop_done; + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); } - __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L17_bool_binop_done:; - - /* "Orange/distance/_distance.pyx":323 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - */ - if (__pyx_t_5) { + __pyx_L18:; + } + __pyx_L13:; + __pyx_L10_continue:; + } - /* "Orange/distance/_distance.pyx":325 - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: - * d += means[col] # <<<<<<<<<<<<<< - * elif val1 != 0 and val2 != 0: - * d += 1 + /* "Orange/distance/_distance.pyx":244 + * d += fabs(val1 - val2) + * + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * + * if not two_tables: */ - __pyx_t_30 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); + __pyx_t_44 = __pyx_v_row1; + __pyx_t_45 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } + } + } - /* "Orange/distance/_distance.pyx":323 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] + /* "Orange/distance/_distance.pyx":210 + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - goto __pyx_L16; - } + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } - /* "Orange/distance/_distance.pyx":326 - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":246 + * distances[row1, row2] = d + * + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ - __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L21_bool_binop_done; - } - __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L21_bool_binop_done:; - if (__pyx_t_5) { + __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_7) { - /* "Orange/distance/_distance.pyx":327 - * d += means[col] - * elif val1 != 0 and val2 != 0: - * d += 1 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":247 + * + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances + * */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":326 - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":246 + * distances[row1, row2] = d + * + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ - } - __pyx_L16:; + } - /* "Orange/distance/_distance.pyx":322 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: + /* "Orange/distance/_distance.pyx":248 + * if not two_tables: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< + * + * */ - goto __pyx_L13; - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "Orange/distance/_distance.pyx":329 - * d += 1 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":188 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ - /*else*/ { - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":330 - * else: - * if npy_isnan(val1): - * d += val2 * means[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += val1 * means[col] - */ - __pyx_t_31 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":329 - * d += 1 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col] - * elif npy_isnan(val2): +/* "Orange/distance/_distance.pyx":251 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] */ - goto __pyx_L23; - } - /* "Orange/distance/_distance.pyx":331 - * if npy_isnan(val1): - * d += val2 * means[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col] - * else: - */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":332 - * d += val2 * means[col] - * elif npy_isnan(val2): - * d += val1 * means[col] # <<<<<<<<<<<<<< - * else: - * d += val1 * val2 - */ - __pyx_t_32 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":331 - * if npy_isnan(val1): - * d += val2 * means[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col] - * else: - */ - goto __pyx_L23; - } - - /* "Orange/distance/_distance.pyx":334 - * d += val1 * means[col] - * else: - * d += val1 * val2 # <<<<<<<<<<<<<< - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); - } - __pyx_L23:; - } - __pyx_L13:; - __pyx_L10_continue:; - } - - /* "Orange/distance/_distance.pyx":335 - * else: - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< - * if d < 0: # clip off any numeric errors - * d = 0 - */ - __pyx_t_33 = __pyx_v_row1; - __pyx_t_34 = __pyx_v_row2; - __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":336 - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: - */ - __pyx_t_5 = ((__pyx_v_d < 0.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":337 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors - * d = 0 # <<<<<<<<<<<<<< - * elif d > 1: - * d = 1 - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":336 - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: - */ - goto __pyx_L24; - } - - /* "Orange/distance/_distance.pyx":338 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[row1, row2] = d - */ - __pyx_t_5 = ((__pyx_v_d > 1.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":339 - * d = 0 - * elif d > 1: - * d = 1 # <<<<<<<<<<<<<< - * distances[row1, row2] = d - * if not two_tables: - */ - __pyx_v_d = 1.0; - - /* "Orange/distance/_distance.pyx":338 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[row1, row2] = d - */ - } - __pyx_L24:; - - /* "Orange/distance/_distance.pyx":340 - * elif d > 1: - * d = 1 - * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) - */ - __pyx_t_35 = __pyx_v_row1; - __pyx_t_36 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } - } +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_12manhattan_cols[] = "manhattan_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12manhattan_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("manhattan_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; } - - /* "Orange/distance/_distance.pyx":312 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * - * with nogil: # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 251, __pyx_L3_error) } - __pyx_L5:; } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 251, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; } - - /* "Orange/distance/_distance.pyx":341 - * d = 1 - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":342 - * distances[row1, row2] = d - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - - /* "Orange/distance/_distance.pyx":341 - * d = 1 - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":343 - * if not two_tables: - * _lower_to_symmetric(distances) - * return distances # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":290 - * - * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, - */ + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 251, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; - goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); - __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abs1, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abs2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":346 - * - * - * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss - */ - -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - double __pyx_v_d; - double __pyx_v_val; - int __pyx_v_row; - int __pyx_v_col; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_v_normalize; int __pyx_v_n_rows; int __pyx_v_n_cols; - int __pyx_v_nan_cont; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + char __pyx_t_3; + npy_intp __pyx_t_4; + npy_intp __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_9; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_t_10; - Py_ssize_t __pyx_t_11; + int __pyx_t_11; int __pyx_t_12; - Py_ssize_t __pyx_t_13; + int __pyx_t_13; int __pyx_t_14; int __pyx_t_15; Py_ssize_t __pyx_t_16; Py_ssize_t __pyx_t_17; - Py_ssize_t __pyx_t_18; + __pyx_t_5numpy_float64_t __pyx_t_18; Py_ssize_t __pyx_t_19; Py_ssize_t __pyx_t_20; - __Pyx_RefNannySetupContext("_abs_cols", 0); + __pyx_t_5numpy_float64_t __pyx_t_21; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + __Pyx_RefNannySetupContext("manhattan_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 251, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":352 - * int row, col, n_rows, n_cols, nan_cont + /* "Orange/distance/_distance.pyx":253 + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< + * double [:] mads = fit_params["mads"] + * char normalize = fit_params["normalize"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 253, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_medians = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":254 + * cdef: + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< + * char normalize = fit_params["normalize"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 254, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_mads = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":255 + * double [:] medians = fit_params["medians"] + * double [:] mads = fit_params["mads"] + * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< + * + * int n_rows, n_cols, col1, col2, row + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_normalize = __pyx_t_3; + + /* "Orange/distance/_distance.pyx":261 + * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * abss = np.empty(n_cols) + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: */ - __pyx_t_1 = (__pyx_v_x.shape[0]); - __pyx_t_2 = (__pyx_v_x.shape[1]); - __pyx_v_n_rows = __pyx_t_1; - __pyx_v_n_cols = __pyx_t_2; + __pyx_t_4 = (__pyx_v_x->dimensions[0]); + __pyx_t_5 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_4; + __pyx_v_n_cols = __pyx_t_5; - /* "Orange/distance/_distance.pyx":353 + /* "Orange/distance/_distance.pyx":262 * * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: - * for col in range(n_cols): + * for col1 in range(n_cols): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_abss = __pyx_t_8; - __pyx_t_8.memview = NULL; - __pyx_t_8.data = NULL; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 262, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 262, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; - /* "Orange/distance/_distance.pyx":354 + /* "Orange/distance/_distance.pyx":263 * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: + * for col1 in range(n_cols): + * for col2 in range(col1): */ { #ifdef WITH_THREAD @@ -7189,282 +5846,441 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":355 - * abss = np.empty(n_cols) + /* "Orange/distance/_distance.pyx":264 + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * abss[col] = 1 + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * d = 0 */ - __pyx_t_9 = __pyx_v_n_cols; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_col = __pyx_t_10; + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col1 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":356 + /* "Orange/distance/_distance.pyx":265 * with nogil: - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * abss[col] = 1 - * continue + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - __pyx_t_11 = __pyx_v_col; - __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_12) { + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":357 - * for col in range(n_cols): - * if vars[col] == -2: - * abss[col] = 1 # <<<<<<<<<<<<<< - * continue - * d = 0 + /* "Orange/distance/_distance.pyx":266 + * for col1 in range(n_cols): + * for col2 in range(col1): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_t_13 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":358 - * if vars[col] == -2: - * abss[col] = 1 - * continue # <<<<<<<<<<<<<< - * d = 0 - * nan_cont = 0 + /* "Orange/distance/_distance.pyx":267 + * for col2 in range(col1): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: */ - goto __pyx_L6_continue; + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":356 - * with nogil: - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * abss[col] = 1 - * continue + /* "Orange/distance/_distance.pyx":268 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) */ - } + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col1; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":359 - * abss[col] = 1 - * continue - * d = 0 # <<<<<<<<<<<<<< - * nan_cont = 0 - * for row in range(n_rows): - */ - __pyx_v_d = 0.0; + /* "Orange/distance/_distance.pyx":269 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + */ + __pyx_t_22 = (__pyx_v_normalize != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":360 - * continue - * d = 0 - * nan_cont = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val = x[row, col] + /* "Orange/distance/_distance.pyx":270 + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): */ - __pyx_v_nan_cont = 0; + __pyx_t_23 = __pyx_v_col1; + __pyx_t_24 = __pyx_v_col1; + __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":361 - * d = 0 - * nan_cont = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val = x[row, col] - * if npy_isnan(val): + /* "Orange/distance/_distance.pyx":271 + * if normalize: + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; + __pyx_t_25 = __pyx_v_col2; + __pyx_t_26 = __pyx_v_col2; + __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":362 - * nan_cont = 0 - * for row in range(n_rows): - * val = x[row, col] # <<<<<<<<<<<<<< - * if npy_isnan(val): - * nan_cont += 1 + /* "Orange/distance/_distance.pyx":272 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col; - __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":363 - * for row in range(n_rows): - * val = x[row, col] - * if npy_isnan(val): # <<<<<<<<<<<<<< - * nan_cont += 1 - * else: + /* "Orange/distance/_distance.pyx":273 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: */ - __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_12) { + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":364 - * val = x[row, col] - * if npy_isnan(val): - * nan_cont += 1 # <<<<<<<<<<<<<< - * else: - * d += val ** 2 + /* "Orange/distance/_distance.pyx":274 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += fabs(val2) + 0.5 */ - __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":363 - * for row in range(n_rows): - * val = x[row, col] - * if npy_isnan(val): # <<<<<<<<<<<<<< - * nan_cont += 1 - * else: + /* "Orange/distance/_distance.pyx":273 + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: */ - goto __pyx_L11; - } + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":366 - * nan_cont += 1 - * else: - * d += val ** 2 # <<<<<<<<<<<<<< - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) + /* "Orange/distance/_distance.pyx":276 + * d += 1 + * else: + * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); - } - __pyx_L11:; - } + /*else*/ { + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + } + __pyx_L14:; - /* "Orange/distance/_distance.pyx":367 - * else: - * d += val ** 2 - * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< - * abss[col] = sqrt(d) - * return abss + /* "Orange/distance/_distance.pyx":272 + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 */ - __pyx_t_18 = __pyx_v_col; - __pyx_t_19 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":368 - * d += val ** 2 - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) # <<<<<<<<<<<<<< - * return abss - * + /* "Orange/distance/_distance.pyx":277 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: */ - __pyx_t_20 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_20 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); - __pyx_L6_continue:; - } - } + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { - /* "Orange/distance/_distance.pyx":354 - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) - * with nogil: # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: + /* "Orange/distance/_distance.pyx":278 + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): + * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":369 - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) - * return abss # <<<<<<<<<<<<<< - * - * + /* "Orange/distance/_distance.pyx":277 + * else: + * d += fabs(val2) + 0.5 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":346 - * - * - * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss + /* "Orange/distance/_distance.pyx":280 + * d += fabs(val1) + 0.5 + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L13:; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_AddTraceback("Orange.distance._distance._abs_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "Orange/distance/_distance.pyx":269 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if normalize: # <<<<<<<<<<<<<< + * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + */ + goto __pyx_L12; + } -/* "Orange/distance/_distance.pyx":372 - * - * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] vars = fit_params["vars"] + /* "Orange/distance/_distance.pyx":282 + * d += fabs(val1 - val2) + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ */ + /*else*/ { + __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_22) { -/* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_12cosine_cols[] = "cosine_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13cosine_cols = {"cosine_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13cosine_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12cosine_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cosine_cols (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 372, __pyx_L3_error) + /* "Orange/distance/_distance.pyx":283 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":284 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + __pyx_t_27 = __pyx_v_col1; + __pyx_t_28 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":285 + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + */ + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":284 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); + + /* "Orange/distance/_distance.pyx":283 + * else: + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) + */ + goto __pyx_L16; + } + + /* "Orange/distance/_distance.pyx":287 + * + fabs(medians[col1] - medians[col2]) + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] + */ + /*else*/ { + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); + } + __pyx_L16:; + + /* "Orange/distance/_distance.pyx":282 + * d += fabs(val1 - val2) + * else: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += mads[col1] + mads[col2] \ + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":288 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + */ + __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_22) { + + /* "Orange/distance/_distance.pyx":289 + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): + * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) + */ + __pyx_t_33 = __pyx_v_col2; + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); + + /* "Orange/distance/_distance.pyx":288 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":291 + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return distances + */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L15:; + } + __pyx_L12:; + } + + /* "Orange/distance/_distance.pyx":292 + * else: + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + __pyx_t_37 = __pyx_v_col2; + __pyx_t_38 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } } } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 372, __pyx_L3_error) + + /* "Orange/distance/_distance.pyx":263 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 372, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + + /* "Orange/distance/_distance.pyx":293 + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d + * return distances # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "Orange/distance/_distance.pyx":251 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 372, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":296 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_14p_nonzero[] = "p_nonzero(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_14p_nonzero}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ goto __pyx_L0; @@ -7475,681 +6291,563 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13cosine_cols(PyObject *_ return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_v_n_rows; - int __pyx_v_n_cols; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { int __pyx_v_row; - int __pyx_v_col1; - int __pyx_v_col2; - double __pyx_v_val1; - double __pyx_v_val2; - double __pyx_v_d; - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyArrayObject *__pyx_v_distances = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; - __Pyx_Buffer __pyx_pybuffer_distances; + int __pyx_v_nonzeros; + int __pyx_v_nonnans; + double __pyx_v_val; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - Py_ssize_t __pyx_t_7; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyArrayObject *__pyx_t_12 = NULL; - int __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - int __pyx_t_17; - Py_ssize_t __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; - Py_ssize_t __pyx_t_21; - int __pyx_t_22; - int __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - __pyx_t_5numpy_float64_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - Py_ssize_t __pyx_t_28; - __pyx_t_5numpy_float64_t __pyx_t_29; - int __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - Py_ssize_t __pyx_t_39; - Py_ssize_t __pyx_t_40; - __Pyx_RefNannySetupContext("cosine_cols", 0); - __pyx_pybuffer_distances.pybuffer.buf = NULL; - __pyx_pybuffer_distances.refcount = 0; - __pyx_pybuffernd_distances.data = NULL; - __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("p_nonzero", 0); __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 372, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 296, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - - /* "Orange/distance/_distance.pyx":374 - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * double [:] means = fit_params["means"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 374, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":375 - * cdef: - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, row, col1, col2 - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 375, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":384 - * np.ndarray[np.float64_t, ndim=2] distances + /* "Orange/distance/_distance.pyx":301 + * double val * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) + * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< + * for row in range(len(x)): + * val = x[row] */ - __pyx_t_3 = (__pyx_v_x->dimensions[0]); - __pyx_t_4 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_v_nonzeros = 0; + __pyx_v_nonnans = 0; - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":302 * - * n_rows, n_cols = x.shape[0], x.shape[1] - * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) + * nonzeros = nonnans = 0 + * for row in range(len(x)): # <<<<<<<<<<<<<< + * val = x[row] + * if not npy_isnan(val): */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 385, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); - if (__pyx_t_6) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 385, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); - } - if (unlikely(!(__pyx_t_6 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 385, __pyx_L1_error) - } - } - #endif + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 302, __pyx_L1_error) + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":386 - * n_rows, n_cols = x.shape[0], x.shape[1] - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): + /* "Orange/distance/_distance.pyx":303 + * nonzeros = nonnans = 0 + * for row in range(len(x)): + * val = x[row] # <<<<<<<<<<<<<< + * if not npy_isnan(val): + * nonnans += 1 */ - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 386, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 386, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_abss = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_t_3 = __pyx_v_row; + __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - /* "Orange/distance/_distance.pyx":387 - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * if vars[col1] == -2: + /* "Orange/distance/_distance.pyx":304 + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); - __pyx_t_1 = 0; - __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 387, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 387, __pyx_L1_error) - __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); - __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack); - if (unlikely(__pyx_t_13 < 0)) { - PyErr_Fetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_14, __pyx_t_15, __pyx_t_16); - } - } - __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 387, __pyx_L1_error) - } - __pyx_t_12 = 0; - __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); + if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":388 - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 + /* "Orange/distance/_distance.pyx":305 + * val = x[row] + * if not npy_isnan(val): + * nonnans += 1 # <<<<<<<<<<<<<< + * if val != 0: + * nonzeros += 1 */ - __pyx_t_13 = __pyx_v_n_cols; - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { - __pyx_v_col1 = __pyx_t_17; + __pyx_v_nonnans = (__pyx_v_nonnans + 1); - /* "Orange/distance/_distance.pyx":389 - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * if vars[col1] == -2: # <<<<<<<<<<<<<< - * distances[col1, :] = distances[:, col1] = 1.0 - * continue + /* "Orange/distance/_distance.pyx":306 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ - __pyx_t_18 = __pyx_v_col1; - __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_6) { + __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":390 - * for col1 in range(n_cols): - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< - * continue - * with nogil: + /* "Orange/distance/_distance.pyx":307 + * nonnans += 1 + * if val != 0: + * nonzeros += 1 # <<<<<<<<<<<<<< + * return float(nonzeros) / nonnans + * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); - __Pyx_INCREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice__2); - __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_slice__3); - __Pyx_GIVEREF(__pyx_slice__3); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__3); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); - __pyx_t_11 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - /* "Orange/distance/_distance.pyx":391 - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 - * continue # <<<<<<<<<<<<<< - * with nogil: - * for col2 in range(col1): + /* "Orange/distance/_distance.pyx":306 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ - goto __pyx_L3_continue; + } - /* "Orange/distance/_distance.pyx":389 - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * if vars[col1] == -2: # <<<<<<<<<<<<<< - * distances[col1, :] = distances[:, col1] = 1.0 - * continue + /* "Orange/distance/_distance.pyx":304 + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: */ } + } - /* "Orange/distance/_distance.pyx":392 - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - * with nogil: # <<<<<<<<<<<<<< - * for col2 in range(col1): - * if vars[col2] == -2: + /* "Orange/distance/_distance.pyx":308 + * if val != 0: + * nonzeros += 1 + * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< + * + * */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; - /* "Orange/distance/_distance.pyx":393 - * continue - * with nogil: - * for col2 in range(col1): # <<<<<<<<<<<<<< - * if vars[col2] == -2: + /* "Orange/distance/_distance.pyx":296 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.p_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":311 + * + * + * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss + */ + +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + double __pyx_v_d; + double __pyx_v_val; + int __pyx_v_row; + int __pyx_v_col; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + Py_ssize_t __pyx_t_13; + int __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + Py_ssize_t __pyx_t_21; + __Pyx_RefNannySetupContext("_abs_rows", 0); + + /* "Orange/distance/_distance.pyx":317 + * int row, col, n_rows, n_cols + * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * abss = np.empty(n_rows) + * with nogil: + */ + __pyx_t_1 = (__pyx_v_x.shape[0]); + __pyx_t_2 = (__pyx_v_x.shape[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; + + /* "Orange/distance/_distance.pyx":318 + * + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) # <<<<<<<<<<<<<< + * with nogil: + * for row in range(n_rows): + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_6) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_abss = __pyx_t_8; + __pyx_t_8.memview = NULL; + __pyx_t_8.data = NULL; + + /* "Orange/distance/_distance.pyx":319 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * d = 0 + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":320 + * abss = np.empty(n_rows) + * with nogil: + * for row in range(n_rows): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): + */ + __pyx_t_9 = __pyx_v_n_rows; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_row = __pyx_t_10; + + /* "Orange/distance/_distance.pyx":321 + * with nogil: + * for row in range(n_rows): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if vars[col] == -2: + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":322 + * for row in range(n_rows): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: * continue */ - __pyx_t_19 = __pyx_v_col1; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col2 = __pyx_t_20; + __pyx_t_11 = __pyx_v_n_cols; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_col = __pyx_t_12; - /* "Orange/distance/_distance.pyx":394 - * with nogil: - * for col2 in range(col1): - * if vars[col2] == -2: # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":323 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< * continue - * d = 0 + * val = x[row, col] */ - __pyx_t_21 = __pyx_v_col2; - __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_6) { + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":395 - * for col2 in range(col1): - * if vars[col2] == -2: + /* "Orange/distance/_distance.pyx":324 + * for col in range(n_cols): + * if vars[col] == -2: * continue # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): + * val = x[row, col] + * if vars[col] == -1: */ - goto __pyx_L11_continue; + goto __pyx_L8_continue; - /* "Orange/distance/_distance.pyx":394 - * with nogil: - * for col2 in range(col1): - * if vars[col2] == -2: # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":323 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< * continue - * d = 0 + * val = x[row, col] */ } - /* "Orange/distance/_distance.pyx":396 - * if vars[col2] == -2: + /* "Orange/distance/_distance.pyx":325 + * if vars[col] == -2: * continue - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + * val = x[row, col] # <<<<<<<<<<<<<< + * if vars[col] == -1: + * if npy_isnan(val): */ - __pyx_v_d = 0.0; + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col; + __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":326 * continue - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): + * val = x[row, col] + * if vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val): + * d += means[col] */ - __pyx_t_22 = __pyx_v_n_rows; - for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { - __pyx_v_row = __pyx_t_23; + __pyx_t_17 = __pyx_v_col; + __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":398 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] + /* "Orange/distance/_distance.pyx":327 + * val = x[row, col] + * if vars[col] == -1: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] + * elif val != 0: */ - __pyx_t_24 = __pyx_v_row; - __pyx_t_25 = __pyx_v_col1; - __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_27 = __pyx_v_row; - __pyx_t_28 = __pyx_v_col2; - __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_26; - __pyx_v_val2 = __pyx_t_29; + __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":399 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += means[col1] * means[col2] - * elif npy_isnan(val1): - */ - __pyx_t_30 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_30) { - } else { - __pyx_t_6 = __pyx_t_30; - goto __pyx_L17_bool_binop_done; - } - __pyx_t_30 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_6 = __pyx_t_30; - __pyx_L17_bool_binop_done:; - if (__pyx_t_6) { - - /* "Orange/distance/_distance.pyx":400 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] # <<<<<<<<<<<<<< - * elif npy_isnan(val1): - * d += val2 * means[col1] + /* "Orange/distance/_distance.pyx":328 + * if vars[col] == -1: + * if npy_isnan(val): + * d += means[col] # <<<<<<<<<<<<<< + * elif val != 0: + * d += 1 */ - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":399 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += means[col1] * means[col2] - * elif npy_isnan(val1): + /* "Orange/distance/_distance.pyx":327 + * val = x[row, col] + * if vars[col] == -1: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] + * elif val != 0: */ - goto __pyx_L16; + goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":401 - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] - * elif npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col1] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":329 + * if npy_isnan(val): + * d += means[col] + * elif val != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: */ - __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_6) { + __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":402 - * d += means[col1] * means[col2] - * elif npy_isnan(val1): - * d += val2 * means[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += val1 * means[col2] + /* "Orange/distance/_distance.pyx":330 + * d += means[col] + * elif val != 0: + * d += 1 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val): */ - __pyx_t_33 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":401 - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] - * elif npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col1] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":329 + * if npy_isnan(val): + * d += means[col] + * elif val != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: */ - goto __pyx_L16; } + __pyx_L12:; - /* "Orange/distance/_distance.pyx":403 - * elif npy_isnan(val1): - * d += val2 * means[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col2] + /* "Orange/distance/_distance.pyx":326 + * continue + * val = x[row, col] + * if vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val): + * d += means[col] + */ + goto __pyx_L11; + } + + /* "Orange/distance/_distance.pyx":332 + * d += 1 + * else: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] ** 2 + vars[col] * else: */ - __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_6) { + /*else*/ { + __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_14) { - /* "Orange/distance/_distance.pyx":404 - * d += val2 * means[col1] - * elif npy_isnan(val2): - * d += val1 * means[col2] # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":333 + * else: + * if npy_isnan(val): + * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< * else: - * d += val1 * val2 + * d += val ** 2 */ - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); + __pyx_t_19 = __pyx_v_col; + __pyx_t_20 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":403 - * elif npy_isnan(val1): - * d += val2 * means[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col2] + /* "Orange/distance/_distance.pyx":332 + * d += 1 + * else: + * if npy_isnan(val): # <<<<<<<<<<<<<< + * d += means[col] ** 2 + vars[col] * else: */ - goto __pyx_L16; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":406 - * d += val1 * means[col2] + /* "Orange/distance/_distance.pyx":335 + * d += means[col] ** 2 + vars[col] * else: - * d += val1 * val2 # <<<<<<<<<<<<<< - * - * d = 1 - d / abss[col1] / abss[col2] + * d += val ** 2 # <<<<<<<<<<<<<< + * abss[row] = sqrt(d) + * return abss */ /*else*/ { - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); + __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); } - __pyx_L16:; + __pyx_L13:; } + __pyx_L11:; + __pyx_L8_continue:; + } - /* "Orange/distance/_distance.pyx":408 - * d += val1 * val2 - * - * d = 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< - * if d < 0: # clip off any numeric errors - * d = 0 - */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":409 + /* "Orange/distance/_distance.pyx":336 + * else: + * d += val ** 2 + * abss[row] = sqrt(d) # <<<<<<<<<<<<<< + * return abss * - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: */ - __pyx_t_6 = ((__pyx_v_d < 0.0) != 0); - if (__pyx_t_6) { + __pyx_t_21 = __pyx_v_row; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_21 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); + } + } - /* "Orange/distance/_distance.pyx":410 - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors - * d = 0 # <<<<<<<<<<<<<< - * elif d > 1: - * d = 1 + /* "Orange/distance/_distance.pyx":319 + * n_rows, n_cols = x.shape[0], x.shape[1] + * abss = np.empty(n_rows) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * d = 0 */ - __pyx_v_d = 0.0; + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } - /* "Orange/distance/_distance.pyx":409 + /* "Orange/distance/_distance.pyx":337 + * d += val ** 2 + * abss[row] = sqrt(d) + * return abss # <<<<<<<<<<<<<< + * * - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: - */ - goto __pyx_L19; - } - - /* "Orange/distance/_distance.pyx":411 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d */ - __pyx_t_6 = ((__pyx_v_d > 1.0) != 0); - if (__pyx_t_6) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; - /* "Orange/distance/_distance.pyx":412 - * d = 0 - * elif d > 1: - * d = 1 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d - * return distances + /* "Orange/distance/_distance.pyx":311 + * + * + * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< + * cdef: + * double [:] abss */ - __pyx_v_d = 1.0; - /* "Orange/distance/_distance.pyx":411 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d - */ - } - __pyx_L19:; + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_AddTraceback("Orange.distance._distance._abs_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":413 - * elif d > 1: - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return distances +/* "Orange/distance/_distance.pyx":340 * - */ - __pyx_t_37 = __pyx_v_col1; - __pyx_t_38 = __pyx_v_col2; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - __pyx_t_39 = __pyx_v_col2; - __pyx_t_40 = __pyx_v_col1; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - __pyx_L11_continue:; - } - } - - /* "Orange/distance/_distance.pyx":392 - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - * with nogil: # <<<<<<<<<<<<<< - * for col2 in range(col1): - * if vars[col2] == -2: - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L10; - } - __pyx_L10:; - } - } - __pyx_L3_continue:; - } - - /* "Orange/distance/_distance.pyx":414 - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d - * return distances # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_distances)); - __pyx_r = ((PyObject *)__pyx_v_distances); - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":372 - * - * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] vars = fit_params["vars"] - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); - __Pyx_XDECREF((PyObject *)__pyx_v_distances); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "Orange/distance/_distance.pyx":417 - * - * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_14jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_14jaccard_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_16cosine_rows[] = "cosine_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17cosine_rows = {"cosine_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17cosine_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16cosine_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; char __pyx_v_two_tables; PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); + __Pyx_RefNannySetupContext("cosine_rows (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; PyObject* values[4] = {0,0,0,0}; @@ -8172,21 +6870,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 417, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 340, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 417, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 340, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 417, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 340, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 417, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 340, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -8198,20 +6896,20 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 419, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L3_error) __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 417, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 340, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 417, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 418, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 340, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 341, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); /* function exit code */ goto __pyx_L0; @@ -8222,8 +6920,10 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15jaccard_rows(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -8232,8 +6932,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU int __pyx_v_col; double __pyx_v_val1; double __pyx_v_val2; - double __pyx_v_intersection; - double __pyx_v_union; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_abs1 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_abs2 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; @@ -8246,32 +6947,38 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU npy_intp __pyx_t_3; npy_intp __pyx_t_4; int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_10; - int __pyx_t_11; - int __pyx_t_12; - int __pyx_t_13; + __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; int __pyx_t_14; int __pyx_t_15; - Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - __pyx_t_5numpy_float64_t __pyx_t_18; - Py_ssize_t __pyx_t_19; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; Py_ssize_t __pyx_t_20; - __pyx_t_5numpy_float64_t __pyx_t_21; + Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; + __pyx_t_5numpy_float64_t __pyx_t_23; Py_ssize_t __pyx_t_24; Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - int __pyx_t_28; + __pyx_t_5numpy_float64_t __pyx_t_26; + int __pyx_t_27; + Py_ssize_t __pyx_t_28; Py_ssize_t __pyx_t_29; Py_ssize_t __pyx_t_30; - __Pyx_RefNannySetupContext("jaccard_rows", 0); + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + __Pyx_RefNannySetupContext("cosine_rows", 0); __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -8282,120 +6989,238 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 417, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 417, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":422 - * fit_params): + /* "Orange/distance/_distance.pyx":345 + * fit_params): * cdef: - * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * double [:] means = fit_params["means"] + * double [:] dist_missing2 = fit_params["dist_missing2"] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 345, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":346 + * cdef: + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< + * double [:] dist_missing2 = fit_params["dist_missing2"] + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 346, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":347 + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] + * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< * * int n_rows1, n_rows2, n_cols, row1, row2, col */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 422, __pyx_L1_error) + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ps = __pyx_t_2; + __pyx_v_dist_missing2 = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":429 + /* "Orange/distance/_distance.pyx":354 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == ps.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ */ __pyx_t_3 = (__pyx_v_x1->dimensions[0]); __pyx_t_4 = (__pyx_v_x1->dimensions[1]); __pyx_v_n_rows1 = __pyx_t_3; __pyx_v_n_cols = __pyx_t_4; - /* "Orange/distance/_distance.pyx":430 + /* "Orange/distance/_distance.pyx":355 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == ps.shape[0] - * + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":431 + /* "Orange/distance/_distance.pyx":356 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); if (__pyx_t_5) { - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); + if (__pyx_t_5) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":357 + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) # <<<<<<<<<<<<<< + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + */ + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); + } + } } + + /* "Orange/distance/_distance.pyx":356 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) + */ if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 431, __pyx_L1_error) + __PYX_ERR(0, 356, __pyx_L1_error) } } #endif - /* "Orange/distance/_distance.pyx":433 - * assert n_cols == x2.shape[1] == ps.shape[0] - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * with nogil: - * for row1 in range(n_rows1): + /* "Orange/distance/_distance.pyx":358 + * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 433, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 358, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 433, __pyx_L1_error) + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + __pyx_v_abs1 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "Orange/distance/_distance.pyx":434 - * + /* "Orange/distance/_distance.pyx":359 + * == len(dist_missing2) + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * with nogil: # <<<<<<<<<<<<<< + * + */ + if ((__pyx_v_two_tables != 0)) { + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = __pyx_t_10; + __pyx_t_10.memview = NULL; + __pyx_t_10.data = NULL; + } else { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = __pyx_t_10; + __pyx_t_10.memview = NULL; + __pyx_t_10.data = NULL; + } + __pyx_v_abs2 = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; + + /* "Orange/distance/_distance.pyx":360 + * abs1 = _abs_rows(x1, means, vars) + * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * + * with nogil: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); + __pyx_t_1 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 360, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; + + /* "Orange/distance/_distance.pyx":362 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * + * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): */ @@ -8406,365 +7231,422 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":435 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) + /* "Orange/distance/_distance.pyx":363 + * * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 + * d = 0 */ - __pyx_t_10 = __pyx_v_n_rows1; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_row1 = __pyx_t_11; + __pyx_t_14 = __pyx_v_n_rows1; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row1 = __pyx_t_15; - /* "Orange/distance/_distance.pyx":436 + /* "Orange/distance/_distance.pyx":364 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * intersection = union = 0 + * d = 0 * for col in range(n_cols): */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_12 = __pyx_v_n_rows2; + __pyx_t_16 = __pyx_v_n_rows2; } else { - __pyx_t_12 = __pyx_v_row1; + __pyx_t_16 = __pyx_v_row1; } - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_row2 = __pyx_t_13; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_row2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":365 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 # <<<<<<<<<<<<<< + * d = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] + * if vars[col] == -2: */ - __pyx_v_intersection = 0.0; - __pyx_v_union = 0.0; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":366 * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 + * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): + * if vars[col] == -2: + * continue */ - __pyx_t_14 = __pyx_v_n_cols; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_col = __pyx_t_15; + __pyx_t_18 = __pyx_v_n_cols; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_col = __pyx_t_19; - /* "Orange/distance/_distance.pyx":439 - * intersection = union = 0 + /* "Orange/distance/_distance.pyx":367 + * d = 0 * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue + * val1, val2 = x1[row1, col], x2[row2, col] */ - __pyx_t_16 = __pyx_v_row1; - __pyx_t_17 = __pyx_v_col; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row2; __pyx_t_20 = __pyx_v_col; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":368 * for col in range(n_cols): + * if vars[col] == -2: + * continue # <<<<<<<<<<<<<< * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 + * if npy_isnan(val1) and npy_isnan(val2): */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + goto __pyx_L10_continue; - /* "Orange/distance/_distance.pyx":441 + /* "Orange/distance/_distance.pyx":367 + * d = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * continue * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":442 - * if npy_isnan(val1): - * if npy_isnan(val2): - * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: */ - __pyx_t_22 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); + } - /* "Orange/distance/_distance.pyx":443 - * if npy_isnan(val2): - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< - * elif val2 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":369 + * if vars[col] == -2: + * continue + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] */ - __pyx_t_23 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); + __pyx_t_21 = __pyx_v_row1; + __pyx_t_22 = __pyx_v_col; + __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_24 = __pyx_v_row2; + __pyx_t_25 = __pyx_v_col; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_23; + __pyx_v_val2 = __pyx_t_26; - /* "Orange/distance/_distance.pyx":441 + /* "Orange/distance/_distance.pyx":370 + * continue * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: */ - goto __pyx_L13; - } + __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L14_bool_binop_done:; + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":444 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":371 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] # <<<<<<<<<<<<<< + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ */ - __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_5) { + __pyx_t_28 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); - /* "Orange/distance/_distance.pyx":445 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 - * else: + /* "Orange/distance/_distance.pyx":370 + * continue + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += dist_missing2[col] + * elif vars[col] == -1: */ - __pyx_t_24 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":446 - * elif val2 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< - * else: - * union += ps[col] + /* "Orange/distance/_distance.pyx":372 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_29 = __pyx_v_col; + __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":444 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":373 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] */ - goto __pyx_L13; + __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); + if (!__pyx_t_27) { + goto __pyx_L18_next_or; + } else { + } + __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); + if (!__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L17_bool_binop_done; } + __pyx_L18_next_or:; - /* "Orange/distance/_distance.pyx":448 - * union += 1 - * else: - * union += ps[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: - */ - /*else*/ { - __pyx_t_25 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); - } - __pyx_L13:; - - /* "Orange/distance/_distance.pyx":440 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 - */ - goto __pyx_L12; - } - - /* "Orange/distance/_distance.pyx":449 - * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":374 + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< + * d += means[col] + * elif val1 != 0 and val2 != 0: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L17_bool_binop_done; + } + __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L17_bool_binop_done:; - /* "Orange/distance/_distance.pyx":450 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":373 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] */ - __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":451 - * elif npy_isnan(val2): - * if val1 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 - * else: + /* "Orange/distance/_distance.pyx":375 + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: + * d += means[col] # <<<<<<<<<<<<<< + * elif val1 != 0 and val2 != 0: + * d += 1 */ - __pyx_t_26 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); + __pyx_t_30 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); - /* "Orange/distance/_distance.pyx":452 - * if val1 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< - * else: - * union += ps[col] + /* "Orange/distance/_distance.pyx":373 + * d += dist_missing2[col] + * elif vars[col] == -1: + * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< + * or npy_isnan(val2) and val1 != 0: + * d += means[col] */ - __pyx_v_union = (__pyx_v_union + 1.0); + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":450 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":376 + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * d += 1 + * else: */ - goto __pyx_L14; + __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_27) { + } else { + __pyx_t_5 = __pyx_t_27; + goto __pyx_L21_bool_binop_done; } + __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_27; + __pyx_L21_bool_binop_done:; + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":454 - * union += 1 - * else: - * union += ps[col] # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":377 + * d += means[col] + * elif val1 != 0 and val2 != 0: + * d += 1 # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val1): + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":376 + * or npy_isnan(val2) and val1 != 0: + * d += means[col] + * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * d += 1 * else: - * if val1 != 0 and val2 != 0: */ - /*else*/ { - __pyx_t_27 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); } - __pyx_L14:; + __pyx_L16:; - /* "Orange/distance/_distance.pyx":449 - * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":372 + * if npy_isnan(val1) and npy_isnan(val2): + * d += dist_missing2[col] + * elif vars[col] == -1: # <<<<<<<<<<<<<< + * if npy_isnan(val1) and val2 != 0 \ + * or npy_isnan(val2) and val1 != 0: */ - goto __pyx_L12; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":456 - * union += ps[col] + /* "Orange/distance/_distance.pyx":379 + * d += 1 * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col] + * elif npy_isnan(val2): */ /*else*/ { - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_5 = __pyx_t_28; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_28; - __pyx_L16_bool_binop_done:; + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":380 * else: - * if val1 != 0 and val2 != 0: - * intersection += 1 # <<<<<<<<<<<<<< - * if val1 != 0 or val2 != 0: - * union += 1 + * if npy_isnan(val1): + * d += val2 * means[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 * means[col] */ - __pyx_v_intersection = (__pyx_v_intersection + 1.0); + __pyx_t_31 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":456 - * union += ps[col] + /* "Orange/distance/_distance.pyx":379 + * d += 1 * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col] + * elif npy_isnan(val2): */ + goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":458 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":381 + * if npy_isnan(val1): + * d += val2 * means[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col] + * else: */ - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_28) { - } else { - __pyx_t_5 = __pyx_t_28; - goto __pyx_L19_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_28; - __pyx_L19_bool_binop_done:; + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":459 - * intersection += 1 - * if val1 != 0 or val2 != 0: - * union += 1 # <<<<<<<<<<<<<< - * if union != 0: - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":382 + * d += val2 * means[col] + * elif npy_isnan(val2): + * d += val1 * means[col] # <<<<<<<<<<<<<< + * else: + * d += val1 * val2 */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_32 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":458 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":381 + * if npy_isnan(val1): + * d += val2 * means[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col] + * else: + */ + goto __pyx_L23; + } + + /* "Orange/distance/_distance.pyx":384 + * d += val1 * means[col] + * else: + * d += val1 * val2 # <<<<<<<<<<<<<< + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors */ + /*else*/ { + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); } + __pyx_L23:; } - __pyx_L12:; + __pyx_L13:; + __pyx_L10_continue:; } - /* "Orange/distance/_distance.pyx":460 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":385 + * else: + * d += val1 * val2 + * d = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< + * if d < 0: # clip off any numeric errors + * d = 0 */ - __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); - if (__pyx_t_5) { + __pyx_t_33 = __pyx_v_row1; + __pyx_t_34 = __pyx_v_row2; + __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":461 - * union += 1 - * if union != 0: - * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< - * - * if not two_tables: + /* "Orange/distance/_distance.pyx":386 + * d += val1 * val2 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: */ - __pyx_t_29 = __pyx_v_row1; - __pyx_t_30 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + __pyx_t_5 = ((__pyx_v_d < 0.0) != 0); + if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":460 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":387 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors + * d = 0 # <<<<<<<<<<<<<< + * elif d > 1: + * d = 1 + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":386 + * d += val1 * val2 + * d = 1 - d / abs1[row1] / abs2[row2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: + */ + goto __pyx_L24; + } + + /* "Orange/distance/_distance.pyx":388 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[row1, row2] = d + */ + __pyx_t_5 = ((__pyx_v_d > 1.0) != 0); + if (__pyx_t_5) { + + /* "Orange/distance/_distance.pyx":389 + * d = 0 + * elif d > 1: + * d = 1 # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * if not two_tables: + */ + __pyx_v_d = 1.0; + + /* "Orange/distance/_distance.pyx":388 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[row1, row2] = d */ } + __pyx_L24:; + + /* "Orange/distance/_distance.pyx":390 + * elif d > 1: + * d = 1 + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if not two_tables: + * _lower_to_symmetric(distances) + */ + __pyx_t_35 = __pyx_v_row1; + __pyx_t_36 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } } } - /* "Orange/distance/_distance.pyx":434 - * + /* "Orange/distance/_distance.pyx":362 * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -8780,9 +7662,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":463 - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":391 + * d = 1 + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances @@ -8790,8 +7672,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_5) { - /* "Orange/distance/_distance.pyx":464 - * + /* "Orange/distance/_distance.pyx":392 + * distances[row1, row2] = d * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances @@ -8799,16 +7681,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":463 - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":391 + * d = 1 + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":465 + /* "Orange/distance/_distance.pyx":393 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -8816,28 +7698,29 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":417 + /* "Orange/distance/_distance.pyx":340 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -8845,238 +7728,130 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14jaccard_rows(CYTHON_UNU __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abs1, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abs2, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":468 +/* "Orange/distance/_distance.pyx":396 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< * cdef: - * double [:] ps = fit_params["ps"] + * double [:] abss */ -/* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_16jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16jaccard_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("jaccard_cols (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 468, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 468, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 468, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 468, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; +static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + double __pyx_v_d; + double __pyx_v_val; + int __pyx_v_row; + int __pyx_v_col; int __pyx_v_n_rows; int __pyx_v_n_cols; - int __pyx_v_col1; - int __pyx_v_col2; - int __pyx_v_row; - double __pyx_v_val1; - double __pyx_v_val2; - int __pyx_v_in_both; - int __pyx_v_in_one; - int __pyx_v_in1_unk2; - int __pyx_v_unk1_in2; - int __pyx_v_unk1_unk2; - int __pyx_v_unk1_not2; - int __pyx_v_not1_unk2; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x; - __Pyx_Buffer __pyx_pybuffer_x; + int __pyx_v_nan_cont; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_t_9; int __pyx_t_10; - int __pyx_t_11; + Py_ssize_t __pyx_t_11; int __pyx_t_12; - int __pyx_t_13; + Py_ssize_t __pyx_t_13; int __pyx_t_14; - Py_ssize_t __pyx_t_15; + int __pyx_t_15; Py_ssize_t __pyx_t_16; - __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_17; Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; - __pyx_t_5numpy_float64_t __pyx_t_20; - int __pyx_t_21; - int __pyx_t_22; - Py_ssize_t __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - Py_ssize_t __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - double __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - __Pyx_RefNannySetupContext("jaccard_cols", 0); - __pyx_pybuffer_x.pybuffer.buf = NULL; - __pyx_pybuffer_x.refcount = 0; - __pyx_pybuffernd_x.data = NULL; - __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 468, __pyx_L1_error) - } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - - /* "Orange/distance/_distance.pyx":470 - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, col1, col2, row - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 470, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ps = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + Py_ssize_t __pyx_t_20; + __Pyx_RefNannySetupContext("_abs_cols", 0); - /* "Orange/distance/_distance.pyx":477 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":402 + * int row, col, n_rows, n_cols, nan_cont * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) + * abss = np.empty(n_cols) * with nogil: */ - __pyx_t_3 = (__pyx_v_x->dimensions[0]); - __pyx_t_4 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_t_1 = (__pyx_v_x.shape[0]); + __pyx_t_2 = (__pyx_v_x.shape[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":478 + /* "Orange/distance/_distance.pyx":403 * * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * abss = np.empty(n_cols) # <<<<<<<<<<<<<< * with nogil: - * for col1 in range(n_cols): + * for col in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 478, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); - __pyx_t_1 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 478, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_6) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 478, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_8; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_abss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "Orange/distance/_distance.pyx":479 + /* "Orange/distance/_distance.pyx":404 * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for col in range(n_cols): + * if vars[col] == -2: */ { #ifdef WITH_THREAD @@ -9085,394 +7860,168 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":480 - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":405 + * abss = np.empty(n_cols) * with nogil: - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * in_both = in_one = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col] == -2: + * abss[col] = 1 */ __pyx_t_9 = __pyx_v_n_cols; for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_col1 = __pyx_t_10; + __pyx_v_col = __pyx_t_10; - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":406 * with nogil: - * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * abss[col] = 1 + * continue */ - __pyx_t_11 = __pyx_v_col1; - for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { - __pyx_v_col2 = __pyx_t_12; + __pyx_t_11 = __pyx_v_col; + __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":482 - * for col1 in range(n_cols): - * for col2 in range(col1): - * in_both = in_one = 0 # <<<<<<<<<<<<<< - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): + /* "Orange/distance/_distance.pyx":407 + * for col in range(n_cols): + * if vars[col] == -2: + * abss[col] = 1 # <<<<<<<<<<<<<< + * continue + * d = 0 */ - __pyx_v_in_both = 0; - __pyx_v_in_one = 0; + __pyx_t_13 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; - /* "Orange/distance/_distance.pyx":483 - * for col2 in range(col1): - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":408 + * if vars[col] == -2: + * abss[col] = 1 + * continue # <<<<<<<<<<<<<< + * d = 0 + * nan_cont = 0 */ - __pyx_v_in1_unk2 = 0; - __pyx_v_unk1_in2 = 0; - __pyx_v_unk1_unk2 = 0; - __pyx_v_unk1_not2 = 0; - __pyx_v_not1_unk2 = 0; + goto __pyx_L6_continue; - /* "Orange/distance/_distance.pyx":484 - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":406 + * with nogil: + * for col in range(n_cols): + * if vars[col] == -2: # <<<<<<<<<<<<<< + * abss[col] = 1 + * continue */ - __pyx_t_13 = __pyx_v_n_rows; - for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { - __pyx_v_row = __pyx_t_14; + } - /* "Orange/distance/_distance.pyx":485 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + /* "Orange/distance/_distance.pyx":409 + * abss[col] = 1 + * continue + * d = 0 # <<<<<<<<<<<<<< + * nan_cont = 0 + * for row in range(n_rows): */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col1; - __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_18 = __pyx_v_row; - __pyx_t_19 = __pyx_v_col2; - __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_17; - __pyx_v_val2 = __pyx_t_20; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":486 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 + /* "Orange/distance/_distance.pyx":410 + * continue + * d = 0 + * nan_cont = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val = x[row, col] */ - __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_21) { + __pyx_v_nan_cont = 0; - /* "Orange/distance/_distance.pyx":487 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":411 + * d = 0 + * nan_cont = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val = x[row, col] + * if npy_isnan(val): */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":488 - * if npy_isnan(val1): - * if npy_isnan(val2): - * unk1_unk2 += 1 # <<<<<<<<<<<<<< - * elif val2 != 0: - * unk1_in2 += 1 + /* "Orange/distance/_distance.pyx":412 + * nan_cont = 0 + * for row in range(n_rows): + * val = x[row, col] # <<<<<<<<<<<<<< + * if npy_isnan(val): + * nan_cont += 1 */ - __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col; + __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); - /* "Orange/distance/_distance.pyx":487 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":413 + * for row in range(n_rows): + * val = x[row, col] + * if npy_isnan(val): # <<<<<<<<<<<<<< + * nan_cont += 1 + * else: */ - goto __pyx_L13; - } + __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); + if (__pyx_t_12) { - /* "Orange/distance/_distance.pyx":489 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 - * else: + /* "Orange/distance/_distance.pyx":414 + * val = x[row, col] + * if npy_isnan(val): + * nan_cont += 1 # <<<<<<<<<<<<<< + * else: + * d += val ** 2 */ - __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_21) { + __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); - /* "Orange/distance/_distance.pyx":490 - * unk1_unk2 += 1 - * elif val2 != 0: - * unk1_in2 += 1 # <<<<<<<<<<<<<< - * else: - * unk1_not2 += 1 + /* "Orange/distance/_distance.pyx":413 + * for row in range(n_rows): + * val = x[row, col] + * if npy_isnan(val): # <<<<<<<<<<<<<< + * nan_cont += 1 + * else: */ - __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); + goto __pyx_L11; + } - /* "Orange/distance/_distance.pyx":489 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 - * else: + /* "Orange/distance/_distance.pyx":416 + * nan_cont += 1 + * else: + * d += val ** 2 # <<<<<<<<<<<<<< + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) */ - goto __pyx_L13; - } + /*else*/ { + __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); + } + __pyx_L11:; + } - /* "Orange/distance/_distance.pyx":492 - * unk1_in2 += 1 - * else: - * unk1_not2 += 1 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: + /* "Orange/distance/_distance.pyx":417 + * else: + * d += val ** 2 + * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< + * abss[col] = sqrt(d) + * return abss */ - /*else*/ { - __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); - } - __pyx_L13:; + __pyx_t_18 = __pyx_v_col; + __pyx_t_19 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); - /* "Orange/distance/_distance.pyx":486 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 - */ - goto __pyx_L12; - } - - /* "Orange/distance/_distance.pyx":493 - * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 - */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":494 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: - */ - __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":495 - * elif npy_isnan(val2): - * if val1 != 0: - * in1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * not1_unk2 += 1 - */ - __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - - /* "Orange/distance/_distance.pyx":494 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: - */ - goto __pyx_L14; - } - - /* "Orange/distance/_distance.pyx":497 - * in1_unk2 += 1 - * else: - * not1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * if val1 != 0 and val2 != 0: - */ - /*else*/ { - __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); - } - __pyx_L14:; - - /* "Orange/distance/_distance.pyx":493 - * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 - */ - goto __pyx_L12; - } - - /* "Orange/distance/_distance.pyx":499 - * not1_unk2 += 1 - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: - */ - /*else*/ { - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L16_bool_binop_done:; - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":500 - * else: - * if val1 != 0 and val2 != 0: - * in_both += 1 # <<<<<<<<<<<<<< - * elif val1 != 0 or val2 != 0: - * in_one += 1 - */ - __pyx_v_in_both = (__pyx_v_in_both + 1); - - /* "Orange/distance/_distance.pyx":499 - * not1_unk2 += 1 - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: - */ - goto __pyx_L15; - } - - /* "Orange/distance/_distance.pyx":501 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ - */ - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L18_bool_binop_done; - } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L18_bool_binop_done:; - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":502 - * in_both += 1 - * elif val1 != 0 or val2 != 0: - * in_one += 1 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - */ - __pyx_v_in_one = (__pyx_v_in_one + 1); - - /* "Orange/distance/_distance.pyx":501 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ - */ - } - __pyx_L15:; - } - __pyx_L12:; - } - - /* "Orange/distance/_distance.pyx":505 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ - */ - __pyx_t_23 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":506 - * 1 - float(in_both - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - */ - __pyx_t_24 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":507 - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - */ - __pyx_t_25 = __pyx_v_col1; - __pyx_t_26 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":509 - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - */ - __pyx_t_27 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":510 - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - * return distances - */ - __pyx_t_28 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":511 - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< - * return distances - */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":504 - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both # <<<<<<<<<<<<<< - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + - */ - __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - - /* "Orange/distance/_distance.pyx":503 - * elif val1 != 0 or val2 != 0: - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< - * 1 - float(in_both - * + ps[col1] * unk1_in2 + + /* "Orange/distance/_distance.pyx":418 + * d += val ** 2 + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) # <<<<<<<<<<<<<< + * return abss + * */ - __pyx_t_32 = __pyx_v_col1; - __pyx_t_33 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; - __pyx_t_34 = __pyx_v_col2; - __pyx_t_35 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; - } + __pyx_t_20 = __pyx_v_col; + *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_20 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); + __pyx_L6_continue:; } } - /* "Orange/distance/_distance.pyx":479 + /* "Orange/distance/_distance.pyx":404 * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + * abss = np.empty(n_cols) * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for col in range(n_cols): + * if vars[col] == -2: */ /*finally:*/ { /*normal exit:*/{ @@ -9485,2883 +8034,3021 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":512 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - * return distances # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":419 + * d += nan_cont * (means[col] ** 2 + vars[col]) + * abss[col] = sqrt(d) + * return abss # <<<<<<<<<<<<<< + * + * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":468 + /* "Orange/distance/_distance.pyx":396 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< * cdef: - * double [:] ps = fit_params["ps"] + * double [:] abss */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_AddTraceback("Orange.distance._distance._abs_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. +/* "Orange/distance/_distance.pyx":422 + * + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] */ /* Python wrapper */ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_18cosine_cols[] = "cosine_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_19cosine_cols = {"cosine_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_19cosine_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_18cosine_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannySetupContext("cosine_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 422, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 422, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 422, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_18cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_copy_shape; - int __pyx_v_i; - int __pyx_v_ndim; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - int __pyx_v_t; - char *__pyx_v_f; - PyArray_Descr *__pyx_v_descr = 0; - int __pyx_v_offset; - int __pyx_v_hasfields; - int __pyx_r; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_row; + int __pyx_v_col1; + int __pyx_v_col2; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyArrayObject *__pyx_v_distances = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - char *__pyx_t_7; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyArrayObject *__pyx_t_12 = NULL; + int __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + int __pyx_t_17; + Py_ssize_t __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + int __pyx_t_22; + int __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + __pyx_t_5numpy_float64_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + __pyx_t_5numpy_float64_t __pyx_t_29; + int __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + __Pyx_RefNannySetupContext("cosine_cols", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 422, __pyx_L1_error) } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 - * # of flags - * - * if info == NULL: return # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":424 + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< + * double [:] means = fit_params["means"] * - * cdef int copy_shape, i, ndim */ - __pyx_t_1 = ((__pyx_v_info == NULL) != 0); - if (__pyx_t_1) { - __pyx_r = 0; - goto __pyx_L0; - } + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 424, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_vars = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 - * - * cdef int copy_shape, i, ndim - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) + /* "Orange/distance/_distance.pyx":425 + * cdef: + * double [:] vars = fit_params["vars"] + * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< * + * int n_rows, n_cols, row, col1, col2 */ - __pyx_v_endian_detector = 1; + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 425, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_means = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 - * cdef int copy_shape, i, ndim - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":434 + * np.ndarray[np.float64_t, ndim=2] distances * - * ndim = PyArray_NDIM(self) + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + __pyx_t_3 = (__pyx_v_x->dimensions[0]); + __pyx_t_4 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":435 * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * n_rows, n_cols = x.shape[0], x.shape[1] + * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< + * abss = _abs_cols(x, means, vars) + * distances = np.zeros((n_cols, n_cols), dtype=float) */ - __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 435, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); + if (__pyx_t_6) { + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 435, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); + } + if (unlikely(!(__pyx_t_6 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 435, __pyx_L1_error) + } + } + #endif - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * ndim = PyArray_NDIM(self) - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: + /* "Orange/distance/_distance.pyx":436 + * n_rows, n_cols = x.shape[0], x.shape[1] + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * copy_shape = 1 # <<<<<<<<<<<<<< - * else: - * copy_shape = 0 - */ - __pyx_v_copy_shape = 1; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 436, __pyx_L1_error) + __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_abss = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * ndim = PyArray_NDIM(self) - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: + /* "Orange/distance/_distance.pyx":437 + * assert n_cols == len(vars) == len(means) + * abss = _abs_cols(x, means, vars) + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * if vars[col1] == -2: */ - goto __pyx_L4; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); + __pyx_t_1 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_13 < 0)) { + PyErr_Fetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_14, __pyx_t_15, __pyx_t_16); + } + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 437, __pyx_L1_error) } + __pyx_t_12 = 0; + __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 - * copy_shape = 1 - * else: - * copy_shape = 0 # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + /* "Orange/distance/_distance.pyx":438 + * abss = _abs_cols(x, means, vars) + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 */ - /*else*/ { - __pyx_v_copy_shape = 0; - } - __pyx_L4:; + __pyx_t_13 = __pyx_v_n_cols; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { + __pyx_v_col1 = __pyx_t_17; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") + /* "Orange/distance/_distance.pyx":439 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + * if vars[col1] == -2: # <<<<<<<<<<<<<< + * distances[col1, :] = distances[:, col1] = 1.0 + * continue */ - __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L6_bool_binop_done; - } + __pyx_t_18 = __pyx_v_col1; + __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not C contiguous") - * + /* "Orange/distance/_distance.pyx":440 + * for col1 in range(n_cols): + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< + * continue + * with nogil: */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L6_bool_binop_done:; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice_); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__2); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); + __pyx_t_11 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") + /* "Orange/distance/_distance.pyx":441 + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 + * continue # <<<<<<<<<<<<<< + * with nogil: + * for col2 in range(col1): */ - if (__pyx_t_1) { + goto __pyx_L3_continue; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + /* "Orange/distance/_distance.pyx":439 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * for col1 in range(n_cols): + * if vars[col1] == -2: # <<<<<<<<<<<<<< + * distances[col1, :] = distances[:, col1] = 1.0 + * continue */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 218, __pyx_L1_error) + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") + /* "Orange/distance/_distance.pyx":442 + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + * with nogil: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * if vars[col2] == -2: */ - } + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") + /* "Orange/distance/_distance.pyx":443 + * continue + * with nogil: + * for col2 in range(col1): # <<<<<<<<<<<<<< + * if vars[col2] == -2: + * continue */ - __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L9_bool_binop_done; - } + __pyx_t_19 = __pyx_v_col1; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { + __pyx_v_col2 = __pyx_t_20; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not Fortran contiguous") - * + /* "Orange/distance/_distance.pyx":444 + * with nogil: + * for col2 in range(col1): + * if vars[col2] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L9_bool_binop_done:; + __pyx_t_21 = __pyx_v_col2; + __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") + /* "Orange/distance/_distance.pyx":445 + * for col2 in range(col1): + * if vars[col2] == -2: + * continue # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - if (__pyx_t_1) { + goto __pyx_L11_continue; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) + /* "Orange/distance/_distance.pyx":444 + * with nogil: + * for col2 in range(col1): + * if vars[col2] == -2: # <<<<<<<<<<<<<< + * continue + * d = 0 */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 222, __pyx_L1_error) + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") + /* "Orange/distance/_distance.pyx":446 + * if vars[col2] == -2: + * continue + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - } + __pyx_v_d = 0.0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 - * raise ValueError(u"ndarray is not Fortran contiguous") - * - * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< - * info.ndim = ndim - * if copy_shape: + /* "Orange/distance/_distance.pyx":447 + * continue + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): */ - __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + __pyx_t_22 = __pyx_v_n_rows; + for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { + __pyx_v_row = __pyx_t_23; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 - * - * info.buf = PyArray_DATA(self) - * info.ndim = ndim # <<<<<<<<<<<<<< - * if copy_shape: - * # Allocate new buffer for strides and shape info. + /* "Orange/distance/_distance.pyx":448 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] */ - __pyx_v_info->ndim = __pyx_v_ndim; + __pyx_t_24 = __pyx_v_row; + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_27 = __pyx_v_row; + __pyx_t_28 = __pyx_v_col2; + __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_26; + __pyx_v_val2 = __pyx_t_29; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 - * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. + /* "Orange/distance/_distance.pyx":449 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += means[col1] * means[col2] + * elif npy_isnan(val1): */ - __pyx_t_1 = (__pyx_v_copy_shape != 0); - if (__pyx_t_1) { + __pyx_t_30 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_30) { + } else { + __pyx_t_6 = __pyx_t_30; + goto __pyx_L17_bool_binop_done; + } + __pyx_t_30 = (npy_isnan(__pyx_v_val2) != 0); + __pyx_t_6 = __pyx_t_30; + __pyx_L17_bool_binop_done:; + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< - * info.shape = info.strides + ndim - * for i in range(ndim): + /* "Orange/distance/_distance.pyx":450 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] # <<<<<<<<<<<<<< + * elif npy_isnan(val1): + * d += val2 * means[col1] */ - __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + __pyx_t_31 = __pyx_v_col1; + __pyx_t_32 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 - * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim # <<<<<<<<<<<<<< - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] + /* "Orange/distance/_distance.pyx":449 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< + * d += means[col1] * means[col2] + * elif npy_isnan(val1): */ - __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + goto __pyx_L16; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim - * for i in range(ndim): # <<<<<<<<<<<<<< - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] + /* "Orange/distance/_distance.pyx":451 + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] + * elif npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col1] + * elif npy_isnan(val2): */ - __pyx_t_4 = __pyx_v_ndim; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 - * info.shape = info.strides + ndim - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< - * info.shape[i] = PyArray_DIMS(self)[i] - * else: + /* "Orange/distance/_distance.pyx":452 + * d += means[col1] * means[col2] + * elif npy_isnan(val1): + * d += val2 * means[col1] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * d += val1 * means[col2] */ - (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + __pyx_t_33 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< - * else: - * info.strides = PyArray_STRIDES(self) + /* "Orange/distance/_distance.pyx":451 + * if npy_isnan(val1) and npy_isnan(val2): + * d += means[col1] * means[col2] + * elif npy_isnan(val1): # <<<<<<<<<<<<<< + * d += val2 * means[col1] + * elif npy_isnan(val2): */ - (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); - } + goto __pyx_L16; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 - * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. + /* "Orange/distance/_distance.pyx":453 + * elif npy_isnan(val1): + * d += val2 * means[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col2] + * else: */ - goto __pyx_L11; - } + __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL + /* "Orange/distance/_distance.pyx":454 + * d += val2 * means[col1] + * elif npy_isnan(val2): + * d += val1 * means[col2] # <<<<<<<<<<<<<< + * else: + * d += val1 * val2 */ - /*else*/ { - __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + __pyx_t_34 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 - * else: - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) + /* "Orange/distance/_distance.pyx":453 + * elif npy_isnan(val1): + * d += val2 * means[col1] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * d += val1 * means[col2] + * else: */ - __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); - } - __pyx_L11:; + goto __pyx_L16; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) + /* "Orange/distance/_distance.pyx":456 + * d += val1 * means[col2] + * else: + * d += val1 * val2 # <<<<<<<<<<<<<< + * + * d = 1 - d / abss[col1] / abss[col2] */ - __pyx_v_info->suboffsets = NULL; + /*else*/ { + __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); + } + __pyx_L16:; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< - * info.readonly = not PyArray_ISWRITEABLE(self) + /* "Orange/distance/_distance.pyx":458 + * d += val1 * val2 * + * d = 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< + * if d < 0: # clip off any numeric errors + * d = 0 */ - __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":459 * - * cdef int t + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: */ - __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + __pyx_t_6 = ((__pyx_v_d < 0.0) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 - * - * cdef int t - * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr - * cdef int offset + /* "Orange/distance/_distance.pyx":460 + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors + * d = 0 # <<<<<<<<<<<<<< + * elif d > 1: + * d = 1 */ - __pyx_v_f = NULL; + __pyx_v_d = 0.0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 - * cdef int t - * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< - * cdef int offset + /* "Orange/distance/_distance.pyx":459 * + * d = 1 - d / abss[col1] / abss[col2] + * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< + * d = 0 + * elif d > 1: */ - __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); - __pyx_t_3 = 0; + goto __pyx_L19; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 - * cdef int offset - * - * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< - * - * if not hasfields and not copy_shape: + /* "Orange/distance/_distance.pyx":461 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + __pyx_t_6 = ((__pyx_v_d > 1.0) != 0); + if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) - * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None + /* "Orange/distance/_distance.pyx":462 + * d = 0 + * elif d > 1: + * d = 1 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return distances */ - __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L15_bool_binop_done; - } - __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L15_bool_binop_done:; - if (__pyx_t_1) { + __pyx_v_d = 1.0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 - * if not hasfields and not copy_shape: - * # do not call releasebuffer - * info.obj = None # <<<<<<<<<<<<<< - * else: - * # need to call releasebuffer + /* "Orange/distance/_distance.pyx":461 + * if d < 0: # clip off any numeric errors + * d = 0 + * elif d > 1: # <<<<<<<<<<<<<< + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = Py_None; + } + __pyx_L19:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) + /* "Orange/distance/_distance.pyx":463 + * elif d > 1: + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return distances * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None */ - goto __pyx_L14; - } + __pyx_t_37 = __pyx_v_col1; + __pyx_t_38 = __pyx_v_col2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; + __pyx_t_39 = __pyx_v_col2; + __pyx_t_40 = __pyx_v_col1; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; + __pyx_L11_continue:; + } + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 - * else: - * # need to call releasebuffer - * info.obj = self # <<<<<<<<<<<<<< - * - * if not hasfields: + /* "Orange/distance/_distance.pyx":442 + * distances[col1, :] = distances[:, col1] = 1.0 + * continue + * with nogil: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * if vars[col2] == -2: */ - /*else*/ { - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L10; + } + __pyx_L10:; + } + } + __pyx_L3_continue:; } - __pyx_L14:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self + /* "Orange/distance/_distance.pyx":464 + * d = 1 + * distances[col1, col2] = distances[col2, col1] = d + * return distances # <<<<<<<<<<<<<< + * * - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_distances)); + __pyx_r = ((PyObject *)__pyx_v_distances); + goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 + /* "Orange/distance/_distance.pyx":422 * - * if not hasfields: - * t = descr.type_num # <<<<<<<<<<<<<< - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] */ - __pyx_t_4 = __pyx_v_descr->type_num; - __pyx_v_t = __pyx_t_4; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); - if (!__pyx_t_2) { - goto __pyx_L20_next_or; - } else { - } - __pyx_t_2 = (__pyx_v_little_endian != 0); - if (!__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; - } - __pyx_L20_next_or:; + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_XDECREF((PyObject *)__pyx_v_distances); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" +/* "Orange/distance/_distance.pyx":467 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ - __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); - if (__pyx_t_2) { + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_20jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_21jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_20jaccard_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 467, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 467, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 467, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 467, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; + 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); } - __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L19_bool_binop_done:; - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - if (__pyx_t_1) { - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 - * if ((descr.byteorder == c'>' and little_endian) or - * (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" - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_v_x1 = ((PyArrayObject *)values[0]); + __pyx_v_x2 = ((PyArrayObject *)values[1]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 469, __pyx_L3_error) + __pyx_v_fit_params = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 467, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 467, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - } + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 - * (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" - */ - switch (__pyx_v_t) { - case NPY_BYTE: - __pyx_v_f = ((char *)"b"); - break; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; + int __pyx_v_n_cols; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_intersection; + double __pyx_v_union; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + int __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + __Pyx_RefNannySetupContext("jaccard_rows", 0); + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 467, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 467, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 - * 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" + /* "Orange/distance/_distance.pyx":472 + * fit_params): + * cdef: + * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< + * + * int n_rows1, n_rows2, n_cols, row1, row2, col */ - case NPY_UBYTE: - __pyx_v_f = ((char *)"B"); - break; + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ps = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 - * 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" + /* "Orange/distance/_distance.pyx":479 + * double [:, :] distances + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == ps.shape[0] */ - case NPY_SHORT: - __pyx_v_f = ((char *)"h"); - break; + __pyx_t_3 = (__pyx_v_x1->dimensions[0]); + __pyx_t_4 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 - * 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" + /* "Orange/distance/_distance.pyx":480 + * + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< + * assert n_cols == x2.shape[1] == ps.shape[0] + * */ - case NPY_USHORT: - __pyx_v_f = ((char *)"H"); - break; + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 - * 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" + /* "Orange/distance/_distance.pyx":481 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] + * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - case NPY_INT: - __pyx_v_f = ((char *)"i"); - break; + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); + if (__pyx_t_5) { + __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); + } + if (unlikely(!(__pyx_t_5 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 481, __pyx_L1_error) + } + } + #endif - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 - * 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" + /* "Orange/distance/_distance.pyx":483 + * assert n_cols == x2.shape[1] == ps.shape[0] + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< + * with nogil: + * for row1 in range(n_rows1): */ - case NPY_UINT: - __pyx_v_f = ((char *)"I"); - break; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 483, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_9; + __pyx_t_9.memview = NULL; + __pyx_t_9.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 - * 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" + /* "Orange/distance/_distance.pyx":484 + * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - case NPY_LONG: - __pyx_v_f = ((char *)"l"); - break; + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 - * 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" + /* "Orange/distance/_distance.pyx":485 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 */ - case NPY_ULONG: - __pyx_v_f = ((char *)"L"); - break; + __pyx_t_10 = __pyx_v_n_rows1; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_row1 = __pyx_t_11; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 - * 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" + /* "Orange/distance/_distance.pyx":486 + * with nogil: + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * intersection = union = 0 + * for col in range(n_cols): */ - case NPY_LONGLONG: - __pyx_v_f = ((char *)"q"); - break; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_12 = __pyx_v_n_rows2; + } else { + __pyx_t_12 = __pyx_v_row1; + } + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row2 = __pyx_t_13; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 - * 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" + /* "Orange/distance/_distance.pyx":487 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] */ - case NPY_ULONGLONG: - __pyx_v_f = ((char *)"Q"); - break; + __pyx_v_intersection = 0.0; + __pyx_v_union = 0.0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 - * 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" + /* "Orange/distance/_distance.pyx":488 + * for row2 in range(n_rows2 if two_tables else row1): + * intersection = union = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): */ - case NPY_FLOAT: - __pyx_v_f = ((char *)"f"); - break; + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 - * 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" + /* "Orange/distance/_distance.pyx":489 + * intersection = union = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - case NPY_DOUBLE: - __pyx_v_f = ((char *)"d"); - break; + __pyx_t_16 = __pyx_v_row1; + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row2; + __pyx_t_20 = __pyx_v_col; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 - * 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" + /* "Orange/distance/_distance.pyx":490 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 */ - case NPY_LONGDOUBLE: - __pyx_v_f = ((char *)"g"); - break; + __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 - * 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" + /* "Orange/distance/_distance.pyx":491 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 */ - case NPY_CFLOAT: - __pyx_v_f = ((char *)"Zf"); - break; + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 - * 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" + /* "Orange/distance/_distance.pyx":492 + * if npy_isnan(val1): + * if npy_isnan(val2): + * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: */ - case NPY_CDOUBLE: - __pyx_v_f = ((char *)"Zd"); - break; + __pyx_t_22 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 - * 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: + /* "Orange/distance/_distance.pyx":493 + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< + * elif val2 != 0: + * intersection += ps[col] */ - case NPY_CLONGDOUBLE: - __pyx_v_f = ((char *)"Zg"); - break; + __pyx_t_23 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 - * 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) + /* "Orange/distance/_distance.pyx":491 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 */ - case NPY_OBJECT: - __pyx_v_f = ((char *)"O"); - break; - default: + goto __pyx_L13; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 - * elif t == NPY_OBJECT: f = "O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * info.format = f - * return + /* "Orange/distance/_distance.pyx":494 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(1, 278, __pyx_L1_error) - break; - } + __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f # <<<<<<<<<<<<<< - * return - * else: + /* "Orange/distance/_distance.pyx":495 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: */ - __pyx_v_info->format = __pyx_v_f; + __pyx_t_24 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f - * return # <<<<<<<<<<<<<< - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) + /* "Orange/distance/_distance.pyx":496 + * elif val2 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ - __pyx_r = 0; - goto __pyx_L0; + __pyx_v_union = (__pyx_v_union + 1.0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self - * - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or + /* "Orange/distance/_distance.pyx":494 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - } + goto __pyx_L13; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 - * return - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - */ - /*else*/ { - __pyx_v_info->format = ((char *)malloc(0xFF)); + /* "Orange/distance/_distance.pyx":498 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: + */ + /*else*/ { + __pyx_t_25 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L13:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, + /* "Orange/distance/_distance.pyx":490 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 */ - (__pyx_v_info->format[0]) = '^'; + goto __pyx_L12; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 - * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 # <<<<<<<<<<<<<< - * f = _util_dtypestring(descr, info.format + 1, - * info.format + _buffer_format_string_len, + /* "Orange/distance/_distance.pyx":499 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] */ - __pyx_v_offset = 0; + __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< - * info.format + _buffer_format_string_len, - * &offset) + /* "Orange/distance/_distance.pyx":500 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) - __pyx_v_f = __pyx_t_7; + __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 - * info.format + _buffer_format_string_len, - * &offset) - * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< - * - * def __releasebuffer__(ndarray self, Py_buffer* info): + /* "Orange/distance/_distance.pyx":501 + * elif npy_isnan(val2): + * if val1 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: */ - (__pyx_v_f[0]) = '\x00'; - } + __pyx_t_26 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + /* "Orange/distance/_distance.pyx":502 + * if val1 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ + __pyx_v_union = (__pyx_v_union + 1.0); - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; - } - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_descr); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "Orange/distance/_distance.pyx":500 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + goto __pyx_L14; + } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 - * f[0] = c'\0' # Terminate format string - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + /* "Orange/distance/_distance.pyx":504 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * else: + * if val1 != 0 and val2 != 0: */ + /*else*/ { + __pyx_t_27 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); + } + __pyx_L14:; -/* Python wrapper */ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); - __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + /* "Orange/distance/_distance.pyx":499 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += ps[col] + */ + goto __pyx_L12; + } - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} + /* "Orange/distance/_distance.pyx":506 + * union += ps[col] + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: + */ + /*else*/ { + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L16_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L16_bool_binop_done:; + if (__pyx_t_5) { -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__releasebuffer__", 0); + /* "Orange/distance/_distance.pyx":507 + * else: + * if val1 != 0 and val2 != 0: + * intersection += 1 # <<<<<<<<<<<<<< + * if val1 != 0 or val2 != 0: + * union += 1 + */ + __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): + /* "Orange/distance/_distance.pyx":506 + * union += ps[col] + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * if val1 != 0 or val2 != 0: */ - __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); - if (__pyx_t_1) { + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) # <<<<<<<<<<<<<< - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) + /* "Orange/distance/_distance.pyx":508 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: */ - free(__pyx_v_info->format); + __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_28) { + } else { + __pyx_t_5 = __pyx_t_28; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_5 = __pyx_t_28; + __pyx_L19_bool_binop_done:; + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): + /* "Orange/distance/_distance.pyx":509 + * intersection += 1 + * if val1 != 0 or val2 != 0: + * union += 1 # <<<<<<<<<<<<<< + * if union != 0: + * distances[row1, row2] = 1 - intersection / union */ - } + __pyx_v_union = (__pyx_v_union + 1.0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) - * # info.shape was stored after info.strides in the same block + /* "Orange/distance/_distance.pyx":508 + * if val1 != 0 and val2 != 0: + * intersection += 1 + * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * union += 1 + * if union != 0: */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { + } + } + __pyx_L12:; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) # <<<<<<<<<<<<<< - * # info.shape was stored after info.strides in the same block + /* "Orange/distance/_distance.pyx":510 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union * */ - free(__pyx_v_info->strides); + __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) - * # info.shape was stored after info.strides in the same block + /* "Orange/distance/_distance.pyx":511 + * union += 1 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< + * + * if not two_tables: */ - } + __pyx_t_29 = __pyx_v_row1; + __pyx_t_30 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 - * f[0] = c'\0' # Terminate format string + /* "Orange/distance/_distance.pyx":510 + * if val1 != 0 or val2 != 0: + * union += 1 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) */ + } + } + } + } - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) + /* "Orange/distance/_distance.pyx":484 * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":513 + * distances[row1, row2] = 1 - intersection / union * - * cdef inline object PyArray_MultiIterNew2(a, b): + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_5) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 - * ctypedef npy_cdouble complex_t + /* "Orange/distance/_distance.pyx":514 * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances * */ + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) + /* "Orange/distance/_distance.pyx":513 + * distances[row1, row2] = 1 - intersection / union * + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ + } -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "Orange/distance/_distance.pyx":515 + * if not two_tables: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * - * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 - * return PyArray_MultiIterNew(1, a) + /* "Orange/distance/_distance.pyx":467 * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 - * return PyArray_MultiIterNew(2, a, b) +/* "Orange/distance/_distance.pyx":518 * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] */ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_22jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_23jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_22jaccard_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyObject *__pyx_v_fit_params = 0; + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ + __Pyx_RefNannySetupContext("jaccard_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 518, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 518, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_fit_params = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 518, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 518, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); /* function exit code */ + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __pyx_r = NULL; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { + __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_v_n_rows; + int __pyx_v_n_cols; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + int __pyx_v_in_both; + int __pyx_v_in_one; + int __pyx_v_in1_unk2; + int __pyx_v_unk1_in2; + int __pyx_v_unk1_unk2; + int __pyx_v_unk1_not2; + int __pyx_v_not1_unk2; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_3; + npy_intp __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + __pyx_t_5numpy_float64_t __pyx_t_20; + int __pyx_t_21; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + double __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + __Pyx_RefNannySetupContext("jaccard_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 518, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) + /* "Orange/distance/_distance.pyx":520 + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): + * cdef: + * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< * + * int n_rows, n_cols, col1, col2, row */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); + if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 520, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ps = __pyx_t_2; + __pyx_t_2.memview = NULL; + __pyx_t_2.data = NULL; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) + /* "Orange/distance/_distance.pyx":527 + * double [:, :] distances * + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: */ + __pyx_t_3 = (__pyx_v_x->dimensions[0]); + __pyx_t_4 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_3; + __pyx_v_n_cols = __pyx_t_4; -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":528 * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * with nogil: + * for col1 in range(n_cols): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); + if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 528, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_distances = __pyx_t_8; + __pyx_t_8.memview = NULL; + __pyx_t_8.data = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * + /* "Orange/distance/_distance.pyx":529 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. + /* "Orange/distance/_distance.pyx":530 + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * in_both = in_one = 0 */ + __pyx_t_9 = __pyx_v_n_cols; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_col1 = __pyx_t_10; -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { - PyArray_Descr *__pyx_v_child = 0; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - PyObject *__pyx_v_fields = 0; - PyObject *__pyx_v_childname = NULL; - PyObject *__pyx_v_new_offset = NULL; - PyObject *__pyx_v_t = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - long __pyx_t_8; - char *__pyx_t_9; - __Pyx_RefNannySetupContext("_util_dtypestring", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 - * - * cdef dtype child - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * cdef tuple fields + /* "Orange/distance/_distance.pyx":531 + * with nogil: + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 */ - __pyx_v_endian_detector = 1; + __pyx_t_11 = __pyx_v_col1; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_col2 = __pyx_t_12; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 - * cdef dtype child - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * cdef tuple fields - * + /* "Orange/distance/_distance.pyx":532 + * for col1 in range(n_cols): + * for col2 in range(col1): + * in_both = in_one = 0 # <<<<<<<<<<<<<< + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + __pyx_v_in_both = 0; + __pyx_v_in_one = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields + /* "Orange/distance/_distance.pyx":533 + * for col2 in range(col1): + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - if (unlikely(__pyx_v_descr->names == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(1, 794, __pyx_L1_error) - } - __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - for (;;) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); - __pyx_t_3 = 0; + __pyx_v_in1_unk2 = 0; + __pyx_v_unk1_in2 = 0; + __pyx_v_unk1_unk2 = 0; + __pyx_v_unk1_not2 = 0; + __pyx_v_not1_unk2 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 - * - * for childname in descr.names: - * fields = descr.fields[childname] # <<<<<<<<<<<<<< - * child, new_offset = fields - * + /* "Orange/distance/_distance.pyx":534 + * in_both = in_one = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): */ - if (unlikely(__pyx_v_descr->fields == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 795, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); - __pyx_t_3 = 0; + __pyx_t_13 = __pyx_v_n_rows; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_v_row = __pyx_t_14; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 - * for childname in descr.names: - * fields = descr.fields[childname] - * child, new_offset = fields # <<<<<<<<<<<<<< - * - * if (end - f) - (new_offset - offset[0]) < 15: + /* "Orange/distance/_distance.pyx":535 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - if (likely(__pyx_v_fields != Py_None)) { - PyObject* sequence = __pyx_v_fields; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(1, 796, __pyx_L1_error) - } - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) - } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); - __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); - __pyx_t_4 = 0; + __pyx_t_15 = __pyx_v_row; + __pyx_t_16 = __pyx_v_col1; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_18 = __pyx_v_row; + __pyx_t_19 = __pyx_v_col2; + __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_17; + __pyx_v_val2 = __pyx_t_20; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * + /* "Orange/distance/_distance.pyx":536 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (__pyx_t_6) { + __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or + /* "Orange/distance/_distance.pyx":537 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * + /* "Orange/distance/_distance.pyx":538 + * if npy_isnan(val1): + * if npy_isnan(val2): + * unk1_unk2 += 1 # <<<<<<<<<<<<<< + * elif val2 != 0: + * unk1_in2 += 1 */ - } + __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") + /* "Orange/distance/_distance.pyx":537 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); - if (!__pyx_t_7) { - goto __pyx_L8_next_or; - } else { - } - __pyx_t_7 = (__pyx_v_little_endian != 0); - if (!__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_L8_next_or:; + goto __pyx_L13; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 - * - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * # One could encode it in the format string and have Cython + /* "Orange/distance/_distance.pyx":539 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); - if (__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_6 = __pyx_t_7; - __pyx_L7_bool_binop_done:; + __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") + /* "Orange/distance/_distance.pyx":540 + * unk1_unk2 += 1 + * elif val2 != 0: + * unk1_in2 += 1 # <<<<<<<<<<<<<< + * else: + * unk1_not2 += 1 */ - if (__pyx_t_6) { + __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply + /* "Orange/distance/_distance.pyx":539 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 803, __pyx_L1_error) + goto __pyx_L13; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") + /* "Orange/distance/_distance.pyx":542 + * unk1_in2 += 1 + * else: + * unk1_not2 += 1 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: */ - } + /*else*/ { + __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); + } + __pyx_L13:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 - * - * # Output padding bytes - * while offset[0] < new_offset: # <<<<<<<<<<<<<< - * f[0] = 120 # "x"; pad byte - * f += 1 + /* "Orange/distance/_distance.pyx":536 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ - while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_6) break; + goto __pyx_L12; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 - * # Output padding bytes - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< - * f += 1 - * offset[0] += 1 + /* "Orange/distance/_distance.pyx":543 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 */ - (__pyx_v_f[0]) = 0x78; + __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte - * f += 1 # <<<<<<<<<<<<<< - * offset[0] += 1 - * + /* "Orange/distance/_distance.pyx":544 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: */ - __pyx_v_f = (__pyx_v_f + 1); + __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 - * f[0] = 120 # "x"; pad byte - * f += 1 - * offset[0] += 1 # <<<<<<<<<<<<<< - * - * offset[0] += child.itemsize + /* "Orange/distance/_distance.pyx":545 + * elif npy_isnan(val2): + * if val1 != 0: + * in1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * not1_unk2 += 1 */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); - } + __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 - * offset[0] += 1 - * - * offset[0] += child.itemsize # <<<<<<<<<<<<<< - * - * if not PyDataType_HASFIELDS(child): + /* "Orange/distance/_distance.pyx":544 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + goto __pyx_L14; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: + /* "Orange/distance/_distance.pyx":547 + * in1_unk2 += 1 + * else: + * not1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * if val1 != 0 and val2 != 0: */ - __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); - if (__pyx_t_6) { + /*else*/ { + __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); + } + __pyx_L14:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 - * - * if not PyDataType_HASFIELDS(child): - * t = child.type_num # <<<<<<<<<<<<<< - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") + /* "Orange/distance/_distance.pyx":543 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); - __pyx_t_4 = 0; + goto __pyx_L12; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * + /* "Orange/distance/_distance.pyx":549 + * not1_unk2 += 1 + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: */ - __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (__pyx_t_6) { + /*else*/ { + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L16_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L16_bool_binop_done:; + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings + /* "Orange/distance/_distance.pyx":550 + * else: + * if val1 != 0 and val2 != 0: + * in_both += 1 # <<<<<<<<<<<<<< + * elif val1 != 0 or val2 != 0: + * in_one += 1 */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_v_in_both = (__pyx_v_in_both + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * + /* "Orange/distance/_distance.pyx":549 + * not1_unk2 += 1 + * else: + * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< + * in_both += 1 + * elif val1 != 0 or val2 != 0: */ - } + goto __pyx_L15; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 - * - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" + /* "Orange/distance/_distance.pyx":551 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 98; - goto __pyx_L15; - } + __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); + if (!__pyx_t_22) { + } else { + __pyx_t_21 = __pyx_t_22; + goto __pyx_L18_bool_binop_done; + } + __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); + __pyx_t_21 = __pyx_t_22; + __pyx_L18_bool_binop_done:; + if (__pyx_t_21) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" + /* "Orange/distance/_distance.pyx":552 + * in_both += 1 + * elif val1 != 0 or val2 != 0: + * in_one += 1 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 66; - goto __pyx_L15; - } + __pyx_v_in_one = (__pyx_v_in_one + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" + /* "Orange/distance/_distance.pyx":551 + * if val1 != 0 and val2 != 0: + * in_both += 1 + * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x68; - goto __pyx_L15; - } + } + __pyx_L15:; + } + __pyx_L12:; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" + /* "Orange/distance/_distance.pyx":555 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 72; - goto __pyx_L15; - } + __pyx_t_23 = __pyx_v_col1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" + /* "Orange/distance/_distance.pyx":556 + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x69; - goto __pyx_L15; - } - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 73; - goto __pyx_L15; - } + __pyx_t_24 = __pyx_v_col2; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" + /* "Orange/distance/_distance.pyx":557 + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x6C; - goto __pyx_L15; - } + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = __pyx_v_col2; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + /* "Orange/distance/_distance.pyx":559 + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 76; - goto __pyx_L15; - } + __pyx_t_27 = __pyx_v_col1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" + /* "Orange/distance/_distance.pyx":560 + * (in_both + in_one + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * return distances */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x71; - goto __pyx_L15; - } + __pyx_t_28 = __pyx_v_col2; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" + /* "Orange/distance/_distance.pyx":561 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< + * return distances */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 81; - goto __pyx_L15; - } + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + /* "Orange/distance/_distance.pyx":554 + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both # <<<<<<<<<<<<<< + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x66; - goto __pyx_L15; - } + __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + /* "Orange/distance/_distance.pyx":553 + * elif val1 != 0 or val2 != 0: + * in_one += 1 + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - float(in_both + * + ps[col1] * unk1_in2 + */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x64; - goto __pyx_L15; + __pyx_t_32 = __pyx_v_col1; + __pyx_t_33 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + __pyx_t_34 = __pyx_v_col2; + __pyx_t_35 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + } + } } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + /* "Orange/distance/_distance.pyx":529 + * n_rows, n_cols = x.shape[0], x.shape[1] + * distances = np.zeros((n_cols, n_cols), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for col1 in range(n_cols): + * for col2 in range(col1): */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x67; - goto __pyx_L15; + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; } + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + /* "Orange/distance/_distance.pyx":562 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * return distances # <<<<<<<<<<<<<< */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x66; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" + /* "Orange/distance/_distance.pyx":518 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x64; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x67; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 79; - goto __pyx_L15; - } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * f += 1 - * else: - */ - /*else*/ { - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 844, __pyx_L1_error) - } - __pyx_L15:; +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * f += 1 # <<<<<<<<<<<<<< - * else: - * # Cython ignores struct boundary information ("T{...}"), - */ - __pyx_v_f = (__pyx_v_f + 1); + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - goto __pyx_L13; - } +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 - * # Cython ignores struct boundary information ("T{...}"), - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< - * return f + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 + * # of flags * - */ - /*else*/ { - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) - __pyx_v_f = __pyx_t_9; - } - __pyx_L13:; - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 - * cdef tuple fields + * if info == NULL: return # <<<<<<<<<<<<<< * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields + * cdef int copy_shape, i, ndim */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) - * return f # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ - __pyx_r = __pyx_v_f; - goto __pyx_L0; + __pyx_v_endian_detector = 1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 - * return PyArray_MultiIterNew(5, a, b, c, d, e) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. + * ndim = PyArray_NDIM(self) */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_child); - __Pyx_XDECREF(__pyx_v_fields); - __Pyx_XDECREF(__pyx_v_childname); - __Pyx_XDECREF(__pyx_v_new_offset); - __Pyx_XDECREF(__pyx_v_t); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 + * cdef bint little_endian = ((&endian_detector)[0] != 0) * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - PyObject *__pyx_v_baseptr; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: */ - __pyx_t_1 = (__pyx_v_base == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 - * cdef PyObject* baseptr - * if base is None: - * baseptr = NULL # <<<<<<<<<<<<<< - * else: - * Py_INCREF(base) # important to do this before decref below! + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 */ - __pyx_v_baseptr = NULL; + __pyx_v_copy_shape = 1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: */ - goto __pyx_L3; + goto __pyx_L4; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 - * baseptr = NULL - * else: - * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< - * baseptr = base - * Py_XDECREF(arr.base) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { - Py_INCREF(__pyx_v_base); + __pyx_v_copy_shape = 0; + } + __pyx_L4:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 - * else: - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base # <<<<<<<<<<<<<< - * Py_XDECREF(arr.base) - * arr.base = baseptr + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") */ - __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L6_bool_binop_done; } - __pyx_L3:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base - * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< - * arr.base = baseptr + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") * */ - Py_XDECREF(__pyx_v_arr->base); + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L6_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 - * baseptr = base - * Py_XDECREF(arr.base) - * arr.base = baseptr # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 * - * cdef inline object get_array_base(ndarray arr): + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") */ - __pyx_v_arr->base = __pyx_v_baseptr; + if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 218, __pyx_L1_error) - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L9_bool_binop_done; + } -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L9_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") * - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< - * return None - * else: + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") */ - __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: - * return None # <<<<<<<<<<<<<< - * else: - * return arr.base + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 222, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") * - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< - * return None - * else: + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 - * return None - * else: - * return arr.base # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); - __pyx_r = ((PyObject *)__pyx_v_arr->base); - goto __pyx_L0; - } + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. */ + __pyx_v_info->ndim = __pyx_v_ndim; - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (__pyx_v_copy_shape != 0); + if (__pyx_t_1) { -/* "View.MemoryView":120 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); -/* Python wrapper */ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_shape = 0; - Py_ssize_t __pyx_v_itemsize; - PyObject *__pyx_v_format = 0; - PyObject *__pyx_v_mode = 0; - int __pyx_v_allocate_buffer; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[3] = ((PyObject *)__pyx_n_s_c); - 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); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 120, __pyx_L3_error) - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 120, __pyx_L3_error) - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 120, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_shape = ((PyObject*)values[0]); - __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 120, __pyx_L3_error) - __pyx_v_format = values[2]; - __pyx_v_mode = values[3]; - if (values[4]) { - __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 121, __pyx_L3_error) - } else { - - /* "View.MemoryView":121 - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, - * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<< - * - * cdef int idx + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] */ - __pyx_v_allocate_buffer = ((int)1); - } - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 120, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 120, __pyx_L1_error) - if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 120, __pyx_L1_error) - } - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "View.MemoryView":120 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] */ + __pyx_t_4 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { - int __pyx_v_idx; - Py_ssize_t __pyx_v_i; - Py_ssize_t __pyx_v_dim; - PyObject **__pyx_v_p; - char __pyx_v_order; - int __pyx_r; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - char *__pyx_t_6; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - __Pyx_RefNannySetupContext("__cinit__", 0); - __Pyx_INCREF(__pyx_v_format); + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } - /* "View.MemoryView":127 - * cdef PyObject **p - * - * self.ndim = len(shape) # <<<<<<<<<<<<<< - * self.itemsize = itemsize - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. */ - if (unlikely(__pyx_v_shape == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(2, 127, __pyx_L1_error) + goto __pyx_L11; } - __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 127, __pyx_L1_error) - __pyx_v_self->ndim = ((int)__pyx_t_1); - /* "View.MemoryView":128 - * - * self.ndim = len(shape) - * self.itemsize = itemsize # <<<<<<<<<<<<<< - * - * if not self.ndim: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL */ - __pyx_v_self->itemsize = __pyx_v_itemsize; + /*else*/ { + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "View.MemoryView":130 - * self.itemsize = itemsize - * - * if not self.ndim: # <<<<<<<<<<<<<< - * raise ValueError("Empty shape tuple for cython.array") - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) */ - __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0); - if (__pyx_t_2) { + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L11:; - /* "View.MemoryView":131 - * - * if not self.ndim: - * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< - * - * if itemsize <= 0: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 131, __pyx_L1_error) + __pyx_v_info->suboffsets = NULL; - /* "View.MemoryView":130 - * self.itemsize = itemsize - * - * if not self.ndim: # <<<<<<<<<<<<<< - * raise ValueError("Empty shape tuple for cython.array") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) * */ - } + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "View.MemoryView":133 - * raise ValueError("Empty shape tuple for cython.array") - * - * if itemsize <= 0: # <<<<<<<<<<<<<< - * raise ValueError("itemsize <= 0 for cython.array") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * + * cdef int t */ - __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0); - if (__pyx_t_2) { + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "View.MemoryView":134 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 * - * if itemsize <= 0: - * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef int offset + */ + __pyx_v_f = NULL; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef int offset * - * if not isinstance(format, bytes): */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 134, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; - /* "View.MemoryView":133 - * raise ValueError("Empty shape tuple for cython.array") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 + * cdef int offset * - * if itemsize <= 0: # <<<<<<<<<<<<<< - * raise ValueError("itemsize <= 0 for cython.array") + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * + * if not hasfields and not copy_shape: */ - } + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "View.MemoryView":136 - * raise ValueError("itemsize <= 0 for cython.array") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) * - * if not isinstance(format, bytes): # <<<<<<<<<<<<<< - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None */ - __pyx_t_2 = PyBytes_Check(__pyx_v_format); - __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0); - if (__pyx_t_4) { + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L15_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L15_bool_binop_done:; + if (__pyx_t_1) { - /* "View.MemoryView":137 - * - * if not isinstance(format, bytes): - * format = format.encode('ASCII') # <<<<<<<<<<<<<< - * self._format = format # keep a reference to the byte string - * self.format = self._format + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); - __pyx_t_5 = 0; + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; - /* "View.MemoryView":136 - * raise ValueError("itemsize <= 0 for cython.array") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) * - * if not isinstance(format, bytes): # <<<<<<<<<<<<<< - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None */ + goto __pyx_L14; } - /* "View.MemoryView":138 - * if not isinstance(format, bytes): - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<< - * self.format = self._format + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< * + * if not hasfields: */ - if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(2, 138, __pyx_L1_error) - __pyx_t_5 = __pyx_v_format; - __Pyx_INCREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_v_self->_format); - __Pyx_DECREF(__pyx_v_self->_format); - __pyx_v_self->_format = ((PyObject*)__pyx_t_5); - __pyx_t_5 = 0; + /*else*/ { + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L14:; - /* "View.MemoryView":139 - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string - * self.format = self._format # <<<<<<<<<<<<<< - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + * info.obj = self * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(2, 139, __pyx_L1_error) - __pyx_v_self->format = __pyx_t_6; + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":142 - * - * - * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<< - * self._strides = self._shape + self.ndim + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): */ - __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2))); + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; - /* "View.MemoryView":143 - * - * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) - * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<< - * - * if not self._shape: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ - __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim); + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L20_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_L20_next_or:; - /* "View.MemoryView":145 - * self._strides = self._shape + self.ndim - * - * if not self._shape: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate shape and strides.") - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" */ - __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0); - if (__pyx_t_4) { + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L19_bool_binop_done:; - /* "View.MemoryView":146 - * - * if not self._shape: - * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< - * - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(2, 146, __pyx_L1_error) + if (__pyx_t_1) { - /* "View.MemoryView":145 - * self._strides = self._shape + self.ndim - * - * if not self._shape: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate shape and strides.") - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * if ((descr.byteorder == c'>' and little_endian) or + * (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" */ - } + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 259, __pyx_L1_error) - /* "View.MemoryView":149 - * - * - * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ - __pyx_t_7 = 0; - __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; - for (;;) { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(2, 149, __pyx_L1_error) - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 149, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_dim = __pyx_t_8; - __pyx_v_idx = __pyx_t_7; - __pyx_t_7 = (__pyx_t_7 + 1); + } - /* "View.MemoryView":150 - * - * for idx, dim in enumerate(shape): - * if dim <= 0: # <<<<<<<<<<<<<< - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * (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_4 = ((__pyx_v_dim <= 0) != 0); - if (__pyx_t_4) { + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = ((char *)"b"); + break; - /* "View.MemoryView":151 - * for idx, dim in enumerate(shape): - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<< - * self._shape[idx] = dim - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * 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_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9); - __pyx_t_3 = 0; - __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_Raise(__pyx_t_9, 0, 0, 0); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __PYX_ERR(2, 151, __pyx_L1_error) + case NPY_UBYTE: + __pyx_v_f = ((char *)"B"); + break; - /* "View.MemoryView":150 - * - * for idx, dim in enumerate(shape): - * if dim <= 0: # <<<<<<<<<<<<<< - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 + * 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" */ - } + case NPY_SHORT: + __pyx_v_f = ((char *)"h"); + break; - /* "View.MemoryView":152 - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim # <<<<<<<<<<<<<< - * - * cdef char order + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * 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_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim; + case NPY_USHORT: + __pyx_v_f = ((char *)"H"); + break; - /* "View.MemoryView":149 - * - * - * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 + * 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_DECREF(__pyx_t_5); __pyx_t_5 = 0; + case NPY_INT: + __pyx_v_f = ((char *)"i"); + break; - /* "View.MemoryView":155 - * - * cdef char order - * if mode == 'fortran': # <<<<<<<<<<<<<< - * order = b'F' - * self.mode = u'fortran' + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * 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_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 155, __pyx_L1_error) - if (__pyx_t_4) { + case NPY_UINT: + __pyx_v_f = ((char *)"I"); + break; - /* "View.MemoryView":156 - * cdef char order - * if mode == 'fortran': - * order = b'F' # <<<<<<<<<<<<<< - * self.mode = u'fortran' - * elif mode == 'c': + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * 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_v_order = 'F'; + case NPY_LONG: + __pyx_v_f = ((char *)"l"); + break; - /* "View.MemoryView":157 - * if mode == 'fortran': - * order = b'F' - * self.mode = u'fortran' # <<<<<<<<<<<<<< - * elif mode == 'c': - * order = b'C' + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 + * 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_INCREF(__pyx_n_u_fortran); - __Pyx_GIVEREF(__pyx_n_u_fortran); - __Pyx_GOTREF(__pyx_v_self->mode); - __Pyx_DECREF(__pyx_v_self->mode); - __pyx_v_self->mode = __pyx_n_u_fortran; + case NPY_ULONG: + __pyx_v_f = ((char *)"L"); + break; - /* "View.MemoryView":155 - * - * cdef char order - * if mode == 'fortran': # <<<<<<<<<<<<<< - * order = b'F' - * self.mode = u'fortran' + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * 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" */ - goto __pyx_L10; - } + case NPY_LONGLONG: + __pyx_v_f = ((char *)"q"); + break; - /* "View.MemoryView":158 - * order = b'F' - * self.mode = u'fortran' - * elif mode == 'c': # <<<<<<<<<<<<<< - * order = b'C' - * self.mode = u'c' + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 + * 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_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 158, __pyx_L1_error) - if (__pyx_t_4) { + case NPY_ULONGLONG: + __pyx_v_f = ((char *)"Q"); + break; - /* "View.MemoryView":159 - * self.mode = u'fortran' - * elif mode == 'c': - * order = b'C' # <<<<<<<<<<<<<< - * self.mode = u'c' - * else: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * 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_v_order = 'C'; + case NPY_FLOAT: + __pyx_v_f = ((char *)"f"); + break; - /* "View.MemoryView":160 - * elif mode == 'c': - * order = b'C' - * self.mode = u'c' # <<<<<<<<<<<<<< - * else: - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 + * 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_INCREF(__pyx_n_u_c); - __Pyx_GIVEREF(__pyx_n_u_c); - __Pyx_GOTREF(__pyx_v_self->mode); - __Pyx_DECREF(__pyx_v_self->mode); - __pyx_v_self->mode = __pyx_n_u_c; + case NPY_DOUBLE: + __pyx_v_f = ((char *)"d"); + break; - /* "View.MemoryView":158 - * order = b'F' - * self.mode = u'fortran' - * elif mode == 'c': # <<<<<<<<<<<<<< - * order = b'C' - * self.mode = u'c' + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * 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" */ - goto __pyx_L10; - } + case NPY_LONGDOUBLE: + __pyx_v_f = ((char *)"g"); + break; - /* "View.MemoryView":162 - * self.mode = u'c' - * else: - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<< - * - * self.len = fill_contig_strides_array(self._shape, self._strides, + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 + * 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" */ - /*else*/ { - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(2, 162, __pyx_L1_error) - } - __pyx_L10:; + case NPY_CFLOAT: + __pyx_v_f = ((char *)"Zf"); + break; - /* "View.MemoryView":164 - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) - * - * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<< - * itemsize, self.ndim, order) - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * 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_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order); + case NPY_CDOUBLE: + __pyx_v_f = ((char *)"Zd"); + break; - /* "View.MemoryView":167 - * itemsize, self.ndim, order) - * - * self.free_data = allocate_buffer # <<<<<<<<<<<<<< - * self.dtype_is_object = format == b'O' - * if allocate_buffer: - */ - __pyx_v_self->free_data = __pyx_v_allocate_buffer; - - /* "View.MemoryView":168 - * - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<< - * if allocate_buffer: - * - */ - __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 168, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 168, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_self->dtype_is_object = __pyx_t_4; - - /* "View.MemoryView":169 - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' - * if allocate_buffer: # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_4 = (__pyx_v_allocate_buffer != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":172 - * - * - * self.data = malloc(self.len) # <<<<<<<<<<<<<< - * if not self.data: - * raise MemoryError("unable to allocate array data.") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * 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_v_self->data = ((char *)malloc(__pyx_v_self->len)); + case NPY_CLONGDOUBLE: + __pyx_v_f = ((char *)"Zg"); + break; - /* "View.MemoryView":173 - * - * self.data = malloc(self.len) - * if not self.data: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate array data.") - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * 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_4 = ((!(__pyx_v_self->data != 0)) != 0); - if (__pyx_t_4) { + case NPY_OBJECT: + __pyx_v_f = ((char *)"O"); + break; + default: - /* "View.MemoryView":174 - * self.data = malloc(self.len) - * if not self.data: - * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< - * - * if self.dtype_is_object: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(2, 174, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(1, 278, __pyx_L1_error) + break; + } - /* "View.MemoryView":173 - * - * self.data = malloc(self.len) - * if not self.data: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate array data.") - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: */ - } + __pyx_v_info->format = __pyx_v_f; - /* "View.MemoryView":176 - * raise MemoryError("unable to allocate array data.") - * - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * p = self.data - * for i in range(self.len / itemsize): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) */ - __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_4) { + __pyx_r = 0; + goto __pyx_L0; - /* "View.MemoryView":177 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + * info.obj = self * - * if self.dtype_is_object: - * p = self.data # <<<<<<<<<<<<<< - * for i in range(self.len / itemsize): - * p[i] = Py_None + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_v_p = ((PyObject **)__pyx_v_self->data); + } - /* "View.MemoryView":178 - * if self.dtype_is_object: - * p = self.data - * for i in range(self.len / itemsize): # <<<<<<<<<<<<<< - * p[i] = Py_None - * Py_INCREF(Py_None) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 */ - if (unlikely(__pyx_v_itemsize == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - __PYX_ERR(2, 178, __pyx_L1_error) - } - else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) { - PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); - __PYX_ERR(2, 178, __pyx_L1_error) - } - __pyx_t_1 = (__pyx_v_self->len / __pyx_v_itemsize); - for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) { - __pyx_v_i = __pyx_t_8; + /*else*/ { + __pyx_v_info->format = ((char *)malloc(0xFF)); - /* "View.MemoryView":179 - * p = self.data - * for i in range(self.len / itemsize): - * p[i] = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, */ - (__pyx_v_p[__pyx_v_i]) = Py_None; + (__pyx_v_info->format[0]) = '^'; - /* "View.MemoryView":180 - * for i in range(self.len / itemsize): - * p[i] = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< - * - * @cname('getbuffer') + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, */ - Py_INCREF(Py_None); - } + __pyx_v_offset = 0; - /* "View.MemoryView":176 - * raise MemoryError("unable to allocate array data.") - * - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * p = self.data - * for i in range(self.len / itemsize): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) */ - } + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) + __pyx_v_f = __pyx_t_7; - /* "View.MemoryView":169 - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' - * if allocate_buffer: # <<<<<<<<<<<<<< - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * + * def __releasebuffer__(ndarray self, Py_buffer* info): */ + (__pyx_v_f[0]) = '\x00'; } - /* "View.MemoryView":120 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ @@ -12369,1197 +11056,1304 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_format); + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":183 +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * f[0] = c'\0' # Terminate format string * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * cdef int bufmode = -1 - * if self.mode == u"c": + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) */ /* Python wrapper */ -static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); - return __pyx_r; } -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_bufmode; - int __pyx_r; +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - Py_ssize_t *__pyx_t_7; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "View.MemoryView":184 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 # <<<<<<<<<<<<<< - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - */ - __pyx_v_bufmode = -1; - - /* "View.MemoryView":185 - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 - * if self.mode == u"c": # <<<<<<<<<<<<<< - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - */ - __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 185, __pyx_L1_error) - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":186 - * cdef int bufmode = -1 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - */ - __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); - - /* "View.MemoryView":185 - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 - * if self.mode == u"c": # <<<<<<<<<<<<<< - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - */ - goto __pyx_L3; - } + __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "View.MemoryView":187 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": # <<<<<<<<<<<<<< - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ - __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 187, __pyx_L1_error) - __pyx_t_1 = (__pyx_t_2 != 0); + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "View.MemoryView":188 - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) */ - __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); + free(__pyx_v_info->format); - /* "View.MemoryView":187 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": # <<<<<<<<<<<<<< - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } - __pyx_L3:; - /* "View.MemoryView":189 - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): # <<<<<<<<<<<<<< - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block */ - __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0); + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "View.MemoryView":190 - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< - * info.buf = self.data - * info.len = self.len + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 190, __pyx_L1_error) + free(__pyx_v_info->strides); - /* "View.MemoryView":189 - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): # <<<<<<<<<<<<<< - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block */ } - /* "View.MemoryView":191 - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data # <<<<<<<<<<<<<< - * info.len = self.len - * info.ndim = self.ndim - */ - __pyx_t_4 = __pyx_v_self->data; - __pyx_v_info->buf = __pyx_t_4; - - /* "View.MemoryView":192 - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data - * info.len = self.len # <<<<<<<<<<<<<< - * info.ndim = self.ndim - * info.shape = self._shape - */ - __pyx_t_5 = __pyx_v_self->len; - __pyx_v_info->len = __pyx_t_5; - - /* "View.MemoryView":193 - * info.buf = self.data - * info.len = self.len - * info.ndim = self.ndim # <<<<<<<<<<<<<< - * info.shape = self._shape - * info.strides = self._strides + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) */ - __pyx_t_6 = __pyx_v_self->ndim; - __pyx_v_info->ndim = __pyx_t_6; - /* "View.MemoryView":194 - * info.len = self.len - * info.ndim = self.ndim - * info.shape = self._shape # <<<<<<<<<<<<<< - * info.strides = self._strides - * info.suboffsets = NULL - */ - __pyx_t_7 = __pyx_v_self->_shape; - __pyx_v_info->shape = __pyx_t_7; + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} - /* "View.MemoryView":195 - * info.ndim = self.ndim - * info.shape = self._shape - * info.strides = self._strides # <<<<<<<<<<<<<< - * info.suboffsets = NULL - * info.itemsize = self.itemsize +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * */ - __pyx_t_7 = __pyx_v_self->_strides; - __pyx_v_info->strides = __pyx_t_7; - /* "View.MemoryView":196 - * info.shape = self._shape - * info.strides = self._strides - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.itemsize = self.itemsize - * info.readonly = 0 - */ - __pyx_v_info->suboffsets = NULL; +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "View.MemoryView":197 - * info.strides = self._strides - * info.suboffsets = NULL - * info.itemsize = self.itemsize # <<<<<<<<<<<<<< - * info.readonly = 0 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): */ - __pyx_t_5 = __pyx_v_self->itemsize; - __pyx_v_info->itemsize = __pyx_t_5; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":198 - * info.suboffsets = NULL - * info.itemsize = self.itemsize - * info.readonly = 0 # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) * - * if flags & PyBUF_FORMAT: */ - __pyx_v_info->readonly = 0; - /* "View.MemoryView":200 - * info.readonly = 0 + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.format - * else: */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); - if (__pyx_t_1) { - /* "View.MemoryView":201 +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 * - * if flags & PyBUF_FORMAT: - * info.format = self.format # <<<<<<<<<<<<<< - * else: - * info.format = NULL + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): */ - __pyx_t_4 = __pyx_v_self->format; - __pyx_v_info->format = __pyx_t_4; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":200 - * info.readonly = 0 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.format - * else: */ - goto __pyx_L5; - } - /* "View.MemoryView":203 - * info.format = self.format - * else: - * info.format = NULL # <<<<<<<<<<<<<< + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) * - * info.obj = self */ - /*else*/ { - __pyx_v_info->format = NULL; - } - __pyx_L5:; - /* "View.MemoryView":205 - * info.format = NULL +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 * - * info.obj = self # <<<<<<<<<<<<<< + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":183 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * cdef int bufmode = -1 - * if self.mode == u"c": */ /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; - } - goto __pyx_L2; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; - } - __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":209 - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) * - * def __dealloc__(array self): # <<<<<<<<<<<<<< - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) */ -/* Python wrapper */ -static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); + return __pyx_r; } -static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__dealloc__", 0); + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "View.MemoryView":210 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 * - * def __dealloc__(array self): - * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< - * self.callback_free_data(self.data) - * elif self.free_data: + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ - __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0); - if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":211 - * def __dealloc__(array self): - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) # <<<<<<<<<<<<<< - * elif self.free_data: - * if self.dtype_is_object: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * */ - __pyx_v_self->callback_free_data(__pyx_v_self->data); - /* "View.MemoryView":210 + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * return PyArray_MultiIterNew(5, a, b, c, d, e) * - * def __dealloc__(array self): - * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< - * self.callback_free_data(self.data) - * elif self.free_data: + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. */ - goto __pyx_L3; - } - /* "View.MemoryView":212 - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - * elif self.free_data: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, - */ - __pyx_t_1 = (__pyx_v_self->free_data != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":213 - * self.callback_free_data(self.data) - * elif self.free_data: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) - */ - __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":214 - * elif self.free_data: - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<< - * self._strides, self.ndim, False) - * free(self.data) - */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0); +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "View.MemoryView":213 - * self.callback_free_data(self.data) - * elif self.free_data: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 + * + * cdef dtype child + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields */ - } + __pyx_v_endian_detector = 1; - /* "View.MemoryView":216 - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) - * free(self.data) # <<<<<<<<<<<<<< - * PyObject_Free(self._shape) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * cdef dtype child + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields * */ - free(__pyx_v_self->data); + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "View.MemoryView":212 - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - * elif self.free_data: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(1, 794, __pyx_L1_error) } - __pyx_L3:; + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; - /* "View.MemoryView":217 - * self._strides, self.ndim, False) - * free(self.data) - * PyObject_Free(self._shape) # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields * - * @property */ - PyObject_Free(__pyx_v_self->_shape); + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 795, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; - /* "View.MemoryView":209 - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< * - * def __dealloc__(array self): # <<<<<<<<<<<<<< - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) + * if (end - f) - (new_offset - offset[0]) < 15: */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 796, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":220 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * child, new_offset = fields * - * @property - * def memview(self): # <<<<<<<<<<<<<< - * return self.get_memview() + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (__pyx_t_6) { -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":221 - * @property - * def memview(self): - * return self.get_memview() # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * - * @cname('get_memview') + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 799, __pyx_L1_error) - /* "View.MemoryView":220 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * child, new_offset = fields * - * @property - * def memview(self): # <<<<<<<<<<<<<< - * return self.get_memview() + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":224 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * - * @cname('get_memview') - * cdef get_memview(self): # <<<<<<<<<<<<<< - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; -static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) { - int __pyx_v_flags; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("get_memview", 0); - - /* "View.MemoryView":225 - * @cname('get_memview') - * cdef get_memview(self): - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<< - * return memoryview(self, flags, self.dtype_is_object) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython */ - __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE); + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; - /* "View.MemoryView":226 - * cdef get_memview(self): - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<< - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __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; - goto __pyx_L0; + if (__pyx_t_6) { - /* "View.MemoryView":224 - * - * @cname('get_memview') - * cdef get_memview(self): # <<<<<<<<<<<<<< - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 803, __pyx_L1_error) - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":229 - * - * - * def __getattr__(self, attr): # <<<<<<<<<<<<<< - * return getattr(self.memview, attr) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") */ + } -/* Python wrapper */ -static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/ -static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__getattr__", 0); + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 0x78; - /* "View.MemoryView":230 - * - * def __getattr__(self, attr): - * return getattr(self.memview, attr) # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 * - * def __getitem__(self, item): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 230, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 230, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + __pyx_v_f = (__pyx_v_f + 1); - /* "View.MemoryView":229 - * - * - * def __getattr__(self, attr): # <<<<<<<<<<<<<< - * return getattr(self.memview, attr) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< * + * offset[0] += child.itemsize */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":232 - * return getattr(self.memview, attr) + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 + * offset[0] += 1 * - * def __getitem__(self, item): # <<<<<<<<<<<<<< - * return self.memview[item] + * offset[0] += child.itemsize # <<<<<<<<<<<<<< * + * if not PyDataType_HASFIELDS(child): */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); -/* Python wrapper */ -static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ -static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__getitem__", 0); - - /* "View.MemoryView":233 - * - * def __getitem__(self, item): - * return self.memview[item] # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + * offset[0] += child.itemsize * - * def __setitem__(self, item, value): + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 233, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 233, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { - /* "View.MemoryView":232 - * return getattr(self.memview, attr) - * - * def __getitem__(self, item): # <<<<<<<<<<<<<< - * return self.memview[item] + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":235 - * return self.memview[item] - * - * def __setitem__(self, item, value): # <<<<<<<<<<<<<< - * self.memview[item] = value + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") * */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_6) { -/* Python wrapper */ -static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setitem__", 0); - - /* "View.MemoryView":236 - * - * def __setitem__(self, item, value): - * self.memview[item] = value # <<<<<<<<<<<<<< - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * + * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 236, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 823, __pyx_L1_error) - /* "View.MemoryView":235 - * return self.memview[item] - * - * def __setitem__(self, item, value): # <<<<<<<<<<<<<< - * self.memview[item] = value + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") * */ + } - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":240 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 * - * @cname("__pyx_array_new") - * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< - * char *mode, char *buf): - * cdef array result + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } -static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { - struct __pyx_array_obj *__pyx_v_result = 0; - struct __pyx_array_obj *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("array_cwrapper", 0); - - /* "View.MemoryView":244 - * cdef array result - * - * if buf == NULL: # <<<<<<<<<<<<<< - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" */ - __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); - if (__pyx_t_1) { + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } - /* "View.MemoryView":245 - * - * if buf == NULL: - * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_shape); - __Pyx_GIVEREF(__pyx_v_shape); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x68; + goto __pyx_L15; + } - /* "View.MemoryView":244 - * cdef array result - * - * if buf == NULL: # <<<<<<<<<<<<<< - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" */ - goto __pyx_L3; - } + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } - /* "View.MemoryView":247 - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< - * allocate_buffer=False) - * result.data = buf + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" */ - /*else*/ { - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_shape); - __Pyx_GIVEREF(__pyx_v_shape); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); - __pyx_t_4 = 0; - __pyx_t_5 = 0; - __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x69; + goto __pyx_L15; + } - /* "View.MemoryView":248 - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), - * allocate_buffer=False) # <<<<<<<<<<<<<< - * result.data = buf - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 248, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } - /* "View.MemoryView":247 - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< - * allocate_buffer=False) - * result.data = buf + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x6C; + goto __pyx_L15; + } - /* "View.MemoryView":249 - * result = array(shape, itemsize, format, mode.decode('ASCII'), - * allocate_buffer=False) - * result.data = buf # <<<<<<<<<<<<<< - * - * return result + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ - __pyx_v_result->data = __pyx_v_buf; - } - __pyx_L3:; + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } - /* "View.MemoryView":251 - * result.data = buf - * - * return result # <<<<<<<<<<<<<< - * - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = __pyx_v_result; - goto __pyx_L0; + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x71; + goto __pyx_L15; + } - /* "View.MemoryView":240 - * - * @cname("__pyx_array_new") - * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< - * char *mode, char *buf): - * cdef array result + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":277 - * cdef class Enum(object): - * cdef object name - * def __init__(self, name): # <<<<<<<<<<<<<< - * self.name = name - * def __repr__(self): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ - -/* Python wrapper */ -static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_name = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; - PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 277, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x66; + goto __pyx_L15; } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_name = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 277, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__", 0); - /* "View.MemoryView":278 - * cdef object name - * def __init__(self, name): - * self.name = name # <<<<<<<<<<<<<< - * def __repr__(self): - * return self.name + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ - __Pyx_INCREF(__pyx_v_name); - __Pyx_GIVEREF(__pyx_v_name); - __Pyx_GOTREF(__pyx_v_self->name); - __Pyx_DECREF(__pyx_v_self->name); - __pyx_v_self->name = __pyx_v_name; + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x64; + goto __pyx_L15; + } - /* "View.MemoryView":277 - * cdef class Enum(object): - * cdef object name - * def __init__(self, name): # <<<<<<<<<<<<<< - * self.name = name - * def __repr__(self): + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x67; + goto __pyx_L15; + } - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":279 - * def __init__(self, name): - * self.name = name - * def __repr__(self): # <<<<<<<<<<<<<< - * return self.name - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x66; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } -/* Python wrapper */ -static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "View.MemoryView":280 - * self.name = name - * def __repr__(self): - * return self.name # <<<<<<<<<<<<<< - * - * cdef generic = Enum("") + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->name); - __pyx_r = __pyx_v_self->name; - goto __pyx_L0; + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x64; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } - /* "View.MemoryView":279 - * def __init__(self, name): - * self.name = name - * def __repr__(self): # <<<<<<<<<<<<<< - * return self.name - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x67; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":294 - * - * @cname('__pyx_align_pointer') - * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } -static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) { - Py_intptr_t __pyx_v_aligned_p; - size_t __pyx_v_offset; - void *__pyx_r; - int __pyx_t_1; - - /* "View.MemoryView":296 - * cdef void *align_pointer(void *memory, size_t alignment) nogil: - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<< - * cdef size_t offset - * + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: */ - __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory); + /*else*/ { + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 844, __pyx_L1_error) + } + __pyx_L15:; - /* "View.MemoryView":300 - * - * with cython.cdivision(True): - * offset = aligned_p % alignment # <<<<<<<<<<<<<< - * - * if offset > 0: + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), */ - __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment); + __pyx_v_f = (__pyx_v_f + 1); - /* "View.MemoryView":302 - * offset = aligned_p % alignment - * - * if offset > 0: # <<<<<<<<<<<<<< - * aligned_p += alignment - offset + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + * offset[0] += child.itemsize * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: */ - __pyx_t_1 = ((__pyx_v_offset > 0) != 0); - if (__pyx_t_1) { + goto __pyx_L13; + } - /* "View.MemoryView":303 - * - * if offset > 0: - * aligned_p += alignment - offset # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f * - * return aligned_p */ - __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset)); + /*else*/ { + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; - /* "View.MemoryView":302 - * offset = aligned_p % alignment - * - * if offset > 0: # <<<<<<<<<<<<<< - * aligned_p += alignment - offset + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * cdef tuple fields * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields */ } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "View.MemoryView":305 - * aligned_p += alignment - offset - * - * return aligned_p # <<<<<<<<<<<<<< + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< * * */ - __pyx_r = ((void *)__pyx_v_aligned_p); + __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "View.MemoryView":294 + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * return PyArray_MultiIterNew(5, a, b, c, d, e) * - * @cname('__pyx_align_pointer') - * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. */ /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":341 - * cdef __Pyx_TypeInfo *typeinfo + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + goto __pyx_L3; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + /*else*/ { + Py_INCREF(__pyx_v_base); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< - * self.obj = obj - * self.flags = flags */ /* Python wrapper */ -static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_obj = 0; - int __pyx_v_flags; - int __pyx_v_dtype_is_object; +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_shape = 0; + Py_ssize_t __pyx_v_itemsize; + PyObject *__pyx_v_format = 0; + PyObject *__pyx_v_mode = 0; + int __pyx_v_allocate_buffer; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0}; - PyObject* values[3] = {0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)__pyx_n_s_c); 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); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -13569,1339 +12363,1257 @@ static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_ar kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 341, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 120, __pyx_L3_error) } case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 120, __pyx_L3_error) + } + case 3: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object); - if (value) { values[2] = value; kw_args--; } + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer); + if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 341, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 120, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } - __pyx_v_obj = values[0]; - __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) - if (values[2]) { - __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) + __pyx_v_shape = ((PyObject*)values[0]); + __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 120, __pyx_L3_error) + __pyx_v_format = values[2]; + __pyx_v_mode = values[3]; + if (values[4]) { + __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 121, __pyx_L3_error) } else { - __pyx_v_dtype_is_object = ((int)0); + + /* "View.MemoryView":121 + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, + * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<< + * + * cdef int idx + */ + __pyx_v_allocate_buffer = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 341, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 120, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 120, __pyx_L1_error) + if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 120, __pyx_L1_error) + } + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); + + /* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { + int __pyx_v_idx; + Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_dim; + PyObject **__pyx_v_p; + char __pyx_v_order; int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; + Py_ssize_t __pyx_t_1; int __pyx_t_2; - int __pyx_t_3; + PyObject *__pyx_t_3 = NULL; int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + char *__pyx_t_6; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_INCREF(__pyx_v_format); - /* "View.MemoryView":342 + /* "View.MemoryView":127 + * cdef PyObject **p + * + * self.ndim = len(shape) # <<<<<<<<<<<<<< + * self.itemsize = itemsize * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): - * self.obj = obj # <<<<<<<<<<<<<< - * self.flags = flags - * if type(self) is memoryview or obj is not None: - */ - __Pyx_INCREF(__pyx_v_obj); - __Pyx_GIVEREF(__pyx_v_obj); - __Pyx_GOTREF(__pyx_v_self->obj); - __Pyx_DECREF(__pyx_v_self->obj); - __pyx_v_self->obj = __pyx_v_obj; - - /* "View.MemoryView":343 - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): - * self.obj = obj - * self.flags = flags # <<<<<<<<<<<<<< - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - */ - __pyx_v_self->flags = __pyx_v_flags; - - /* "View.MemoryView":344 - * self.obj = obj - * self.flags = flags - * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: */ - __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type)); - __pyx_t_3 = (__pyx_t_2 != 0); - if (!__pyx_t_3) { - } else { - __pyx_t_1 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; + if (unlikely(__pyx_v_shape == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(2, 127, __pyx_L1_error) } - __pyx_t_3 = (__pyx_v_obj != Py_None); - __pyx_t_2 = (__pyx_t_3 != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { - - /* "View.MemoryView":345 - * self.flags = flags - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<< - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None - */ - __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 345, __pyx_L1_error) - - /* "View.MemoryView":346 - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) - */ - __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0); - if (__pyx_t_1) { + __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 127, __pyx_L1_error) + __pyx_v_self->ndim = ((int)__pyx_t_1); - /* "View.MemoryView":347 - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) + /* "View.MemoryView":128 + * + * self.ndim = len(shape) + * self.itemsize = itemsize # <<<<<<<<<<<<<< * + * if not self.ndim: */ - ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None; + __pyx_v_self->itemsize = __pyx_v_itemsize; - /* "View.MemoryView":348 - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + /* "View.MemoryView":130 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") * - * global __pyx_memoryview_thread_locks_used */ - Py_INCREF(Py_None); + __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":346 - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) + /* "View.MemoryView":131 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: */ - } + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 131, __pyx_L1_error) - /* "View.MemoryView":344 - * self.obj = obj - * self.flags = flags - * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: + /* "View.MemoryView":130 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") + * */ } - /* "View.MemoryView":351 + /* "View.MemoryView":133 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") * - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - */ - __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":352 - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: */ - __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":353 - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<< - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() + /* "View.MemoryView":134 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): */ - __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 134, __pyx_L1_error) - /* "View.MemoryView":351 + /* "View.MemoryView":133 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") * - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 */ } - /* "View.MemoryView":354 - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: # <<<<<<<<<<<<<< - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: + /* "View.MemoryView":136 + * raise ValueError("itemsize <= 0 for cython.array") + * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string */ - __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); - if (__pyx_t_1) { + __pyx_t_2 = PyBytes_Check(__pyx_v_format); + __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_4) { - /* "View.MemoryView":355 - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<< - * if self.lock is NULL: - * raise MemoryError + /* "View.MemoryView":137 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format */ - __pyx_v_self->lock = PyThread_allocate_lock(); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); + __pyx_t_5 = 0; - /* "View.MemoryView":356 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: # <<<<<<<<<<<<<< - * raise MemoryError + /* "View.MemoryView":136 + * raise ValueError("itemsize <= 0 for cython.array") * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string */ - __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); - if (__pyx_t_1) { + } - /* "View.MemoryView":357 - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: - * raise MemoryError # <<<<<<<<<<<<<< + /* "View.MemoryView":138 + * if not isinstance(format, bytes): + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<< + * self.format = self._format * - * if flags & PyBUF_FORMAT: */ - PyErr_NoMemory(); __PYX_ERR(2, 357, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(2, 138, __pyx_L1_error) + __pyx_t_5 = __pyx_v_format; + __Pyx_INCREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_v_self->_format); + __Pyx_DECREF(__pyx_v_self->_format); + __pyx_v_self->_format = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; - /* "View.MemoryView":356 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: # <<<<<<<<<<<<<< - * raise MemoryError + /* "View.MemoryView":139 + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + * self.format = self._format # <<<<<<<<<<<<<< + * * */ - } + __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(2, 139, __pyx_L1_error) + __pyx_v_self->format = __pyx_t_6; - /* "View.MemoryView":354 - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: # <<<<<<<<<<<<<< - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: + /* "View.MemoryView":142 + * + * + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<< + * self._strides = self._shape + self.ndim + * */ - } + __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2))); - /* "View.MemoryView":359 - * raise MemoryError + /* "View.MemoryView":143 * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) + * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<< + * + * if not self._shape: */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); - if (__pyx_t_1) { + __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim); - /* "View.MemoryView":360 + /* "View.MemoryView":145 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") * - * if flags & PyBUF_FORMAT: - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<< - * else: - * self.dtype_is_object = dtype_is_object */ - __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L11_bool_binop_done:; - __pyx_v_self->dtype_is_object = __pyx_t_1; + __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0); + if (__pyx_t_4) { - /* "View.MemoryView":359 - * raise MemoryError + /* "View.MemoryView":146 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: */ - goto __pyx_L10; - } + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 146, __pyx_L1_error) - /* "View.MemoryView":362 - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: - * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<< + /* "View.MemoryView":145 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") * - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( */ - /*else*/ { - __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object; } - __pyx_L10:; - /* "View.MemoryView":364 - * self.dtype_is_object = dtype_is_object + /* "View.MemoryView":149 * - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<< - * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) - * self.typeinfo = NULL - */ - __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int)))); - - /* "View.MemoryView":366 - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( - * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) - * self.typeinfo = NULL # <<<<<<<<<<<<<< * - * def __dealloc__(memoryview self): + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) */ - __pyx_v_self->typeinfo = NULL; + __pyx_t_7 = 0; + __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(2, 149, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 149, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 149, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_dim = __pyx_t_8; + __pyx_v_idx = __pyx_t_7; + __pyx_t_7 = (__pyx_t_7 + 1); - /* "View.MemoryView":341 - * cdef __Pyx_TypeInfo *typeinfo + /* "View.MemoryView":150 * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< - * self.obj = obj - * self.flags = flags + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim */ + __pyx_t_4 = ((__pyx_v_dim <= 0) != 0); + if (__pyx_t_4) { - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":368 - * self.typeinfo = NULL + /* "View.MemoryView":151 + * for idx, dim in enumerate(shape): + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<< + * self._shape[idx] = dim * - * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9); + __pyx_t_3 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_Raise(__pyx_t_9, 0, 0, 0); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __PYX_ERR(2, 151, __pyx_L1_error) -/* Python wrapper */ -static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { - int __pyx_v_i; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - PyThread_type_lock __pyx_t_5; - PyThread_type_lock __pyx_t_6; - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "View.MemoryView":369 - * - * def __dealloc__(memoryview self): - * if self.obj is not None: # <<<<<<<<<<<<<< - * __Pyx_ReleaseBuffer(&self.view) + /* "View.MemoryView":150 * + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim */ - __pyx_t_1 = (__pyx_v_self->obj != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { + } - /* "View.MemoryView":370 - * def __dealloc__(memoryview self): - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<< + /* "View.MemoryView":152 + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim # <<<<<<<<<<<<<< * - * cdef int i + * cdef char order */ - __Pyx_ReleaseBuffer((&__pyx_v_self->view)); + (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim; - /* "View.MemoryView":369 + /* "View.MemoryView":149 * - * def __dealloc__(memoryview self): - * if self.obj is not None: # <<<<<<<<<<<<<< - * __Pyx_ReleaseBuffer(&self.view) * + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) */ - } - - /* "View.MemoryView":374 - * cdef int i - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: # <<<<<<<<<<<<<< - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: - */ - __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":375 - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<< - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - */ - __pyx_t_3 = __pyx_memoryview_thread_locks_used; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "View.MemoryView":376 - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: + /* "View.MemoryView":155 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' */ - __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0); - if (__pyx_t_2) { + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 155, __pyx_L1_error) + if (__pyx_t_4) { - /* "View.MemoryView":377 - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<< - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + /* "View.MemoryView":156 + * cdef char order + * if mode == 'fortran': + * order = b'F' # <<<<<<<<<<<<<< + * self.mode = u'fortran' + * elif mode == 'c': */ - __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1); + __pyx_v_order = 'F'; - /* "View.MemoryView":378 - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + /* "View.MemoryView":157 + * if mode == 'fortran': + * order = b'F' + * self.mode = u'fortran' # <<<<<<<<<<<<<< + * elif mode == 'c': + * order = b'C' */ - __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0); - if (__pyx_t_2) { + __Pyx_INCREF(__pyx_n_u_fortran); + __Pyx_GIVEREF(__pyx_n_u_fortran); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_fortran; - /* "View.MemoryView":380 - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<< - * break - * else: + /* "View.MemoryView":155 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' */ - __pyx_t_5 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); - __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_v_i]); + goto __pyx_L10; + } - /* "View.MemoryView":379 - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - * break + /* "View.MemoryView":158 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' */ - (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_5; - (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_6; + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 158, __pyx_L1_error) + if (__pyx_t_4) { - /* "View.MemoryView":378 - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + /* "View.MemoryView":159 + * self.mode = u'fortran' + * elif mode == 'c': + * order = b'C' # <<<<<<<<<<<<<< + * self.mode = u'c' + * else: */ - } + __pyx_v_order = 'C'; - /* "View.MemoryView":381 - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - * break # <<<<<<<<<<<<<< - * else: - * PyThread_free_lock(self.lock) + /* "View.MemoryView":160 + * elif mode == 'c': + * order = b'C' + * self.mode = u'c' # <<<<<<<<<<<<<< + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) */ - goto __pyx_L6_break; + __Pyx_INCREF(__pyx_n_u_c); + __Pyx_GIVEREF(__pyx_n_u_c); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_c; - /* "View.MemoryView":376 - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: + /* "View.MemoryView":158 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' */ - } - } - /*else*/ { + goto __pyx_L10; + } - /* "View.MemoryView":383 - * break - * else: - * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<< + /* "View.MemoryView":162 + * self.mode = u'c' + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<< * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: - */ - PyThread_free_lock(__pyx_v_self->lock); - } - __pyx_L6_break:; - - /* "View.MemoryView":374 - * cdef int i - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: # <<<<<<<<<<<<<< - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: + * self.len = fill_contig_strides_array(self._shape, self._strides, */ + /*else*/ { + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 162, __pyx_L1_error) } + __pyx_L10:; - /* "View.MemoryView":368 - * self.typeinfo = NULL + /* "View.MemoryView":164 + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + * + * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<< + * itemsize, self.ndim, order) * - * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) */ + __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order); - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":385 - * PyThread_free_lock(self.lock) + /* "View.MemoryView":167 + * itemsize, self.ndim, order) * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf + * self.free_data = allocate_buffer # <<<<<<<<<<<<<< + * self.dtype_is_object = format == b'O' + * if allocate_buffer: */ + __pyx_v_self->free_data = __pyx_v_allocate_buffer; -static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { - Py_ssize_t __pyx_v_dim; - char *__pyx_v_itemp; - PyObject *__pyx_v_idx = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - PyObject *(*__pyx_t_4)(PyObject *); - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - char *__pyx_t_7; - __Pyx_RefNannySetupContext("get_item_pointer", 0); - - /* "View.MemoryView":387 - * cdef char *get_item_pointer(memoryview self, object index) except NULL: - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<< + /* "View.MemoryView":168 + * + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<< + * if allocate_buffer: * - * for dim, idx in enumerate(index): */ - __pyx_v_itemp = ((char *)__pyx_v_self->view.buf); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 168, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 168, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_self->dtype_is_object = __pyx_t_4; - /* "View.MemoryView":389 - * cdef char *itemp = self.view.buf + /* "View.MemoryView":169 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< * - * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< - * itemp = pybuffer_index(&self.view, itemp, idx, dim) * */ - __pyx_t_1 = 0; - if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) { - __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; - __pyx_t_4 = NULL; - } else { - __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 389, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 389, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_4)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_4(__pyx_t_2); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(2, 389, __pyx_L1_error) - } - break; - } + __pyx_t_4 = (__pyx_v_allocate_buffer != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":172 + * + * + * self.data = malloc(self.len) # <<<<<<<<<<<<<< + * if not self.data: + * raise MemoryError("unable to allocate array data.") + */ + __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len)); + + /* "View.MemoryView":173 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ + __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":174 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 174, __pyx_L1_error) + + /* "View.MemoryView":173 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ } - __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_v_dim = __pyx_t_1; - __pyx_t_1 = (__pyx_t_1 + 1); - /* "View.MemoryView":390 + /* "View.MemoryView":176 + * raise MemoryError("unable to allocate array data.") * - * for dim, idx in enumerate(index): - * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<< + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":177 * - * return itemp + * if self.dtype_is_object: + * p = self.data # <<<<<<<<<<<<<< + * for i in range(self.len / itemsize): + * p[i] = Py_None */ - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 390, __pyx_L1_error) - __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(2, 390, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_7; + __pyx_v_p = ((PyObject **)__pyx_v_self->data); - /* "View.MemoryView":389 - * cdef char *itemp = self.view.buf + /* "View.MemoryView":178 + * if self.dtype_is_object: + * p = self.data + * for i in range(self.len / itemsize): # <<<<<<<<<<<<<< + * p[i] = Py_None + * Py_INCREF(Py_None) + */ + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(2, 178, __pyx_L1_error) + } + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(2, 178, __pyx_L1_error) + } + __pyx_t_1 = (__pyx_v_self->len / __pyx_v_itemsize); + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "View.MemoryView":179 + * p = self.data + * for i in range(self.len / itemsize): + * p[i] = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) * - * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< - * itemp = pybuffer_index(&self.view, itemp, idx, dim) + */ + (__pyx_v_p[__pyx_v_i]) = Py_None; + + /* "View.MemoryView":180 + * for i in range(self.len / itemsize): + * p[i] = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< * + * @cname('getbuffer') */ - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + Py_INCREF(Py_None); + } - /* "View.MemoryView":392 - * itemp = pybuffer_index(&self.view, itemp, idx, dim) + /* "View.MemoryView":176 + * raise MemoryError("unable to allocate array data.") * - * return itemp # <<<<<<<<<<<<<< + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + } + + /* "View.MemoryView":169 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< * * */ - __pyx_r = __pyx_v_itemp; - goto __pyx_L0; + } - /* "View.MemoryView":385 - * PyThread_free_lock(self.lock) + /* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf */ /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_idx); + __Pyx_XDECREF(__pyx_v_format); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":395 - * +/* "View.MemoryView":183 * - * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< - * if index is Ellipsis: - * return self + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": */ /* Python wrapper */ -static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ -static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { - PyObject *__pyx_r = 0; +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { - PyObject *__pyx_v_have_slices = NULL; - PyObject *__pyx_v_indices = NULL; - char *__pyx_v_itemp; - PyObject *__pyx_r = NULL; +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_bufmode; + int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - char *__pyx_t_6; - __Pyx_RefNannySetupContext("__getitem__", 0); + char *__pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + Py_ssize_t *__pyx_t_7; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } - /* "View.MemoryView":396 - * - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: # <<<<<<<<<<<<<< - * return self - * + /* "View.MemoryView":184 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 # <<<<<<<<<<<<<< + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS */ - __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis); + __pyx_v_bufmode = -1; + + /* "View.MemoryView":185 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + */ + __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 185, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "View.MemoryView":397 - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: - * return self # <<<<<<<<<<<<<< - * - * have_slices, indices = _unellipsify(index, self.view.ndim) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __pyx_r = ((PyObject *)__pyx_v_self); - goto __pyx_L0; - - /* "View.MemoryView":396 - * - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: # <<<<<<<<<<<<<< - * return self - * + /* "View.MemoryView":186 + * cdef int bufmode = -1 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS */ - } + __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); - /* "View.MemoryView":399 - * return self - * - * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< - * - * cdef char *itemp + /* "View.MemoryView":185 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": */ - __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 399, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (likely(__pyx_t_3 != Py_None)) { - PyObject* sequence = __pyx_t_3; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(2, 399, __pyx_L1_error) - } - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 399, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 399, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 399, __pyx_L1_error) + goto __pyx_L3; } - __pyx_v_have_slices = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_v_indices = __pyx_t_5; - __pyx_t_5 = 0; - /* "View.MemoryView":402 - * - * cdef char *itemp - * if have_slices: # <<<<<<<<<<<<<< - * return memview_slice(self, indices) - * else: + /* "View.MemoryView":187 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 402, __pyx_L1_error) - if (__pyx_t_2) { + __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 187, __pyx_L1_error) + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { - /* "View.MemoryView":403 - * cdef char *itemp - * if have_slices: - * return memview_slice(self, indices) # <<<<<<<<<<<<<< - * else: - * itemp = self.get_item_pointer(indices) + /* "View.MemoryView":188 + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 403, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); - /* "View.MemoryView":402 - * - * cdef char *itemp - * if have_slices: # <<<<<<<<<<<<<< - * return memview_slice(self, indices) - * else: + /* "View.MemoryView":187 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): */ } + __pyx_L3:; - /* "View.MemoryView":405 - * return memview_slice(self, indices) - * else: - * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<< - * return self.convert_item_to_object(itemp) - * + /* "View.MemoryView":189 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data */ - /*else*/ { - __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 405, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_6; + __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":406 - * else: - * itemp = self.get_item_pointer(indices) - * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<< - * - * def __setitem__(memoryview self, object index, object value): + /* "View.MemoryView":190 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 406, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 190, __pyx_L1_error) + + /* "View.MemoryView":189 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + */ } - /* "View.MemoryView":395 - * - * - * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< - * if index is Ellipsis: - * return self + /* "View.MemoryView":191 + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data # <<<<<<<<<<<<<< + * info.len = self.len + * info.ndim = self.ndim */ + __pyx_t_4 = __pyx_v_self->data; + __pyx_v_info->buf = __pyx_t_4; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_have_slices); - __Pyx_XDECREF(__pyx_v_indices); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":192 + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + * info.len = self.len # <<<<<<<<<<<<<< + * info.ndim = self.ndim + * info.shape = self._shape + */ + __pyx_t_5 = __pyx_v_self->len; + __pyx_v_info->len = __pyx_t_5; -/* "View.MemoryView":408 - * return self.convert_item_to_object(itemp) - * - * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< - * have_slices, index = _unellipsify(index, self.view.ndim) - * + /* "View.MemoryView":193 + * info.buf = self.data + * info.len = self.len + * info.ndim = self.ndim # <<<<<<<<<<<<<< + * info.shape = self._shape + * info.strides = self._strides */ + __pyx_t_6 = __pyx_v_self->ndim; + __pyx_v_info->ndim = __pyx_t_6; -/* Python wrapper */ -static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); + /* "View.MemoryView":194 + * info.len = self.len + * info.ndim = self.ndim + * info.shape = self._shape # <<<<<<<<<<<<<< + * info.strides = self._strides + * info.suboffsets = NULL + */ + __pyx_t_7 = __pyx_v_self->_shape; + __pyx_v_info->shape = __pyx_t_7; - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":195 + * info.ndim = self.ndim + * info.shape = self._shape + * info.strides = self._strides # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = self.itemsize + */ + __pyx_t_7 = __pyx_v_self->_strides; + __pyx_v_info->strides = __pyx_t_7; -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - PyObject *__pyx_v_have_slices = NULL; - PyObject *__pyx_v_obj = NULL; - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - __Pyx_RefNannySetupContext("__setitem__", 0); - __Pyx_INCREF(__pyx_v_index); + /* "View.MemoryView":196 + * info.shape = self._shape + * info.strides = self._strides + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = self.itemsize + * info.readonly = 0 + */ + __pyx_v_info->suboffsets = NULL; - /* "View.MemoryView":409 - * - * def __setitem__(memoryview self, object index, object value): - * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + /* "View.MemoryView":197 + * info.strides = self._strides + * info.suboffsets = NULL + * info.itemsize = self.itemsize # <<<<<<<<<<<<<< + * info.readonly = 0 * - * if have_slices: */ - __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 409, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (likely(__pyx_t_1 != Py_None)) { - PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(2, 409, __pyx_L1_error) - } - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 409, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 409, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 409, __pyx_L1_error) - } - __pyx_v_have_slices = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_5 = __pyx_v_self->itemsize; + __pyx_v_info->itemsize = __pyx_t_5; - /* "View.MemoryView":411 - * have_slices, index = _unellipsify(index, self.view.ndim) + /* "View.MemoryView":198 + * info.suboffsets = NULL + * info.itemsize = self.itemsize + * info.readonly = 0 # <<<<<<<<<<<<<< * - * if have_slices: # <<<<<<<<<<<<<< - * obj = self.is_slice(value) - * if obj: + * if flags & PyBUF_FORMAT: */ - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 411, __pyx_L1_error) - if (__pyx_t_4) { + __pyx_v_info->readonly = 0; - /* "View.MemoryView":412 + /* "View.MemoryView":200 + * info.readonly = 0 * - * if have_slices: - * obj = self.is_slice(value) # <<<<<<<<<<<<<< - * if obj: - * self.setitem_slice_assignment(self[index], obj) - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 412, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_obj = __pyx_t_1; - __pyx_t_1 = 0; - - /* "View.MemoryView":413 - * if have_slices: - * obj = self.is_slice(value) - * if obj: # <<<<<<<<<<<<<< - * self.setitem_slice_assignment(self[index], obj) - * else: - */ - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 413, __pyx_L1_error) - if (__pyx_t_4) { - - /* "View.MemoryView":414 - * obj = self.is_slice(value) - * if obj: - * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<< - * else: - * self.setitem_slice_assign_scalar(self[index], value) - */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 414, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 414, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":413 - * if have_slices: - * obj = self.is_slice(value) - * if obj: # <<<<<<<<<<<<<< - * self.setitem_slice_assignment(self[index], obj) - * else: + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: */ - goto __pyx_L4; - } + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":416 - * self.setitem_slice_assignment(self[index], obj) - * else: - * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<< + /* "View.MemoryView":201 + * + * if flags & PyBUF_FORMAT: + * info.format = self.format # <<<<<<<<<<<<<< * else: - * self.setitem_indexed(index, value) + * info.format = NULL */ - /*else*/ { - __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 416, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 416, __pyx_L1_error) - __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 416, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __pyx_L4:; + __pyx_t_4 = __pyx_v_self->format; + __pyx_v_info->format = __pyx_t_4; - /* "View.MemoryView":411 - * have_slices, index = _unellipsify(index, self.view.ndim) + /* "View.MemoryView":200 + * info.readonly = 0 * - * if have_slices: # <<<<<<<<<<<<<< - * obj = self.is_slice(value) - * if obj: + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: */ - goto __pyx_L3; + goto __pyx_L5; } - /* "View.MemoryView":418 - * self.setitem_slice_assign_scalar(self[index], value) + /* "View.MemoryView":203 + * info.format = self.format * else: - * self.setitem_indexed(index, value) # <<<<<<<<<<<<<< + * info.format = NULL # <<<<<<<<<<<<<< * - * cdef is_slice(self, obj): + * info.obj = self */ /*else*/ { - __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 418, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_info->format = NULL; } - __pyx_L3:; + __pyx_L5:; - /* "View.MemoryView":408 - * return self.convert_item_to_object(itemp) + /* "View.MemoryView":205 + * info.format = NULL * - * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< - * have_slices, index = _unellipsify(index, self.view.ndim) + * info.obj = self # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "View.MemoryView":183 * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": */ /* 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_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_have_slices); - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XDECREF(__pyx_v_index); + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":420 - * self.setitem_indexed(index, value) +/* "View.MemoryView":209 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") * - * cdef is_slice(self, obj): # <<<<<<<<<<<<<< - * if not isinstance(obj, memoryview): - * try: + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) */ -static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) { - PyObject *__pyx_r = NULL; +/* Python wrapper */ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - __Pyx_RefNannySetupContext("is_slice", 0); - __Pyx_INCREF(__pyx_v_obj); + __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "View.MemoryView":421 + /* "View.MemoryView":210 * - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< - * try: - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: */ - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { + __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":422 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) + /* "View.MemoryView":211 + * def __dealloc__(array self): + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) # <<<<<<<<<<<<<< + * elif self.free_data: + * if self.dtype_is_object: */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_4); - __Pyx_XGOTREF(__pyx_t_5); - /*try:*/ { + __pyx_v_self->callback_free_data(__pyx_v_self->data); - /* "View.MemoryView":423 - * if not isinstance(obj, memoryview): - * try: - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< - * self.dtype_is_object) - * except TypeError: + /* "View.MemoryView":210 + * + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: */ - __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 423, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_6); + goto __pyx_L3; + } - /* "View.MemoryView":424 - * try: - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) # <<<<<<<<<<<<<< - * except TypeError: - * return None + /* "View.MemoryView":212 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, */ - __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 424, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = (__pyx_v_self->free_data != 0); + if (__pyx_t_1) { - /* "View.MemoryView":423 - * if not isinstance(obj, memoryview): - * try: - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< - * self.dtype_is_object) - * except TypeError: + /* "View.MemoryView":213 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) */ - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 423, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_v_obj); - __Pyx_GIVEREF(__pyx_v_obj); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); - __pyx_t_6 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 423, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7); - __pyx_t_7 = 0; + __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_1) { - /* "View.MemoryView":422 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) + /* "View.MemoryView":214 + * elif self.free_data: + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<< + * self._strides, self.ndim, False) + * free(self.data) */ - } - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L11_try_end; - __pyx_L4_error:; - __Pyx_PyThreadState_assign - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0); - /* "View.MemoryView":425 - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) - * except TypeError: # <<<<<<<<<<<<<< - * return None - * + /* "View.MemoryView":213 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) */ - __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); - if (__pyx_t_9) { - __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 425, __pyx_L6_except_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GOTREF(__pyx_t_6); + } - /* "View.MemoryView":426 - * self.dtype_is_object) - * except TypeError: - * return None # <<<<<<<<<<<<<< + /* "View.MemoryView":216 + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + * free(self.data) # <<<<<<<<<<<<<< + * PyObject_Free(self._shape) * - * return obj - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L7_except_return; - } - goto __pyx_L6_except_error; - __pyx_L6_except_error:; - - /* "View.MemoryView":422 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) */ - __Pyx_PyThreadState_assign - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); - goto __pyx_L1_error; - __pyx_L7_except_return:; - __Pyx_PyThreadState_assign - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); - goto __pyx_L0; - __pyx_L11_try_end:; - } + free(__pyx_v_self->data); - /* "View.MemoryView":421 - * - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< - * try: - * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + /* "View.MemoryView":212 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, */ } + __pyx_L3:; - /* "View.MemoryView":428 - * return None - * - * return obj # <<<<<<<<<<<<<< + /* "View.MemoryView":217 + * self._strides, self.ndim, False) + * free(self.data) + * PyObject_Free(self._shape) # <<<<<<<<<<<<<< * - * cdef setitem_slice_assignment(self, dst, src): + * @property */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_obj); - __pyx_r = __pyx_v_obj; - goto __pyx_L0; + PyObject_Free(__pyx_v_self->_shape); - /* "View.MemoryView":420 - * self.setitem_indexed(index, value) + /* "View.MemoryView":209 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") * - * cdef is_slice(self, obj): # <<<<<<<<<<<<<< - * if not isinstance(obj, memoryview): - * try: + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) */ /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -/* "View.MemoryView":430 - * return obj +/* "View.MemoryView":220 + * + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() * - * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice dst_slice - * cdef __Pyx_memviewslice src_slice */ -static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) { - __Pyx_memviewslice __pyx_v_dst_slice; - __Pyx_memviewslice __pyx_v_src_slice; +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - __Pyx_RefNannySetupContext("setitem_slice_assignment", 0); + __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":434 - * cdef __Pyx_memviewslice src_slice + /* "View.MemoryView":221 + * @property + * def memview(self): + * return self.get_memview() # <<<<<<<<<<<<<< * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) + * @cname('get_memview') */ - if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 434, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":435 + /* "View.MemoryView":220 * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], - * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<< - * src.ndim, dst.ndim, self.dtype_is_object) + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() * */ - if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 435, __pyx_L1_error) - /* "View.MemoryView":436 - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<< + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":224 * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "View.MemoryView":434 - * cdef __Pyx_memviewslice src_slice +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) { + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_memview", 0); + + /* "View.MemoryView":225 + * @cname('get_memview') + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<< + * return memoryview(self, flags, self.dtype_is_object) * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) */ - __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 434, __pyx_L1_error) + __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE); - /* "View.MemoryView":430 - * return obj + /* "View.MemoryView":226 + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<< * - * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice dst_slice - * cdef __Pyx_memviewslice src_slice + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 226, __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; + goto __pyx_L0; + + /* "View.MemoryView":224 + * + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -14909,5092 +13621,5081 @@ static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryvi return __pyx_r; } -/* "View.MemoryView":438 - * src.ndim, dst.ndim, self.dtype_is_object) +/* "View.MemoryView":229 + * + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< - * cdef int array[128] - * cdef void *tmp = NULL */ -static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { - int __pyx_v_array[0x80]; - void *__pyx_v_tmp; - void *__pyx_v_item; - __Pyx_memviewslice *__pyx_v_dst_slice; - __Pyx_memviewslice __pyx_v_tmp_slice; +/* Python wrapper */ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; + PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - char const *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0); + __Pyx_RefNannySetupContext("__getattr__", 0); - /* "View.MemoryView":440 - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): - * cdef int array[128] - * cdef void *tmp = NULL # <<<<<<<<<<<<<< - * cdef void *item + /* "View.MemoryView":230 + * + * def __getattr__(self, attr): + * return getattr(self.memview, attr) # <<<<<<<<<<<<<< * + * def __getitem__(self, item): */ - __pyx_v_tmp = NULL; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; - /* "View.MemoryView":445 - * cdef __Pyx_memviewslice *dst_slice - * cdef __Pyx_memviewslice tmp_slice - * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<< + /* "View.MemoryView":229 + * + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) * - * if self.view.itemsize > sizeof(array): */ - __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); - /* "View.MemoryView":447 - * dst_slice = get_slice_from_memview(dst, &tmp_slice) + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":232 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] * - * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: */ - __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0); - if (__pyx_t_1) { - /* "View.MemoryView":448 +/* Python wrapper */ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "View.MemoryView":233 * - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<< - * if tmp == NULL: - * raise MemoryError + * def __getitem__(self, item): + * return self.memview[item] # <<<<<<<<<<<<<< + * + * def __setitem__(self, item, value): */ - __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; - /* "View.MemoryView":449 - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * item = tmp + /* "View.MemoryView":232 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] + * */ - __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0); - if (__pyx_t_1) { - /* "View.MemoryView":450 - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: - * raise MemoryError # <<<<<<<<<<<<<< - * item = tmp - * else: - */ - PyErr_NoMemory(); __PYX_ERR(2, 450, __pyx_L1_error) - - /* "View.MemoryView":449 - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * item = tmp - */ - } - - /* "View.MemoryView":451 - * if tmp == NULL: - * raise MemoryError - * item = tmp # <<<<<<<<<<<<<< - * else: - * item = array - */ - __pyx_v_item = __pyx_v_tmp; - - /* "View.MemoryView":447 - * dst_slice = get_slice_from_memview(dst, &tmp_slice) - * - * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":453 - * item = tmp - * else: - * item = array # <<<<<<<<<<<<<< - * - * try: - */ - /*else*/ { - __pyx_v_item = ((void *)__pyx_v_array); - } - __pyx_L3:; + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":455 - * item = array +/* "View.MemoryView":235 + * return self.memview[item] * - * try: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * ( item)[0] = value - */ - /*try:*/ { - - /* "View.MemoryView":456 + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value * - * try: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * ( item)[0] = value - * else: - */ - __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":457 - * try: - * if self.dtype_is_object: - * ( item)[0] = value # <<<<<<<<<<<<<< - * else: - * self.assign_item_from_object( item, value) */ - (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value); - /* "View.MemoryView":456 - * - * try: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * ( item)[0] = value - * else: - */ - goto __pyx_L8; - } +/* Python wrapper */ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); - /* "View.MemoryView":459 - * ( item)[0] = value - * else: - * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 459, __pyx_L6_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_L8:; + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":463 - * - * - * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - */ - __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0); - if (__pyx_t_1) { +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setitem__", 0); - /* "View.MemoryView":464 + /* "View.MemoryView":236 * - * if self.view.suboffsets != NULL: - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<< - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - * item, self.dtype_is_object) - */ - __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 464, __pyx_L6_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "View.MemoryView":463 + * def __setitem__(self, item, value): + * self.memview[item] = value # <<<<<<<<<<<<<< * * - * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - */ - } - - /* "View.MemoryView":465 - * if self.view.suboffsets != NULL: - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<< - * item, self.dtype_is_object) - * finally: */ - __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object); - } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 236, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "View.MemoryView":468 - * item, self.dtype_is_object) - * finally: - * PyMem_Free(tmp) # <<<<<<<<<<<<<< + /* "View.MemoryView":235 + * return self.memview[item] * - * cdef setitem_indexed(self, index, value): - */ - /*finally:*/ { - /*normal exit:*/{ - PyMem_Free(__pyx_v_tmp); - goto __pyx_L7; - } - /*exception exit:*/{ - __Pyx_PyThreadState_declare - __pyx_L6_error:; - __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; - __Pyx_PyThreadState_assign - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); - if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); - __Pyx_XGOTREF(__pyx_t_6); - __Pyx_XGOTREF(__pyx_t_7); - __Pyx_XGOTREF(__pyx_t_8); - __Pyx_XGOTREF(__pyx_t_9); - __Pyx_XGOTREF(__pyx_t_10); - __Pyx_XGOTREF(__pyx_t_11); - __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename; - { - PyMem_Free(__pyx_v_tmp); - } - __Pyx_PyThreadState_assign - if (PY_MAJOR_VERSION >= 3) { - __Pyx_XGIVEREF(__pyx_t_9); - __Pyx_XGIVEREF(__pyx_t_10); - __Pyx_XGIVEREF(__pyx_t_11); - __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); - } - __Pyx_XGIVEREF(__pyx_t_6); - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_XGIVEREF(__pyx_t_8); - __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8); - __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; - __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5; - goto __pyx_L1_error; - } - __pyx_L7:; - } - - /* "View.MemoryView":438 - * src.ndim, dst.ndim, self.dtype_is_object) + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< - * cdef int array[128] - * cdef void *tmp = NULL */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":470 - * PyMem_Free(tmp) +/* "View.MemoryView":240 * - * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result */ -static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - char *__pyx_v_itemp; - PyObject *__pyx_r = NULL; +static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { + struct __pyx_array_obj *__pyx_v_result = 0; + struct __pyx_array_obj *__pyx_r = NULL; __Pyx_RefNannyDeclarations - char *__pyx_t_1; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("setitem_indexed", 0); + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("array_cwrapper", 0); - /* "View.MemoryView":471 - * - * cdef setitem_indexed(self, index, value): - * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<< - * self.assign_item_from_object(itemp, value) + /* "View.MemoryView":244 + * cdef array result * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: */ - __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(2, 471, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_1; + __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":472 - * cdef setitem_indexed(self, index, value): - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<< + /* "View.MemoryView":245 * - * cdef convert_item_to_object(self, char *itemp): + * if buf == NULL: + * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), */ - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 472, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4); + __pyx_t_4 = 0; - /* "View.MemoryView":470 - * PyMem_Free(tmp) + /* "View.MemoryView":244 + * cdef array result * - * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: */ + goto __pyx_L3; + } - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":474 - * self.assign_item_from_object(itemp, value) - * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" + /* "View.MemoryView":247 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf */ + /*else*/ { + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_3 = 0; -static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) { - PyObject *__pyx_v_struct = NULL; - PyObject *__pyx_v_bytesitem = 0; - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - size_t __pyx_t_10; - int __pyx_t_11; - int __pyx_t_12; - __Pyx_RefNannySetupContext("convert_item_to_object", 0); - - /* "View.MemoryView":477 - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - * import struct # <<<<<<<<<<<<<< - * cdef bytes bytesitem + /* "View.MemoryView":248 + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) # <<<<<<<<<<<<<< + * result.data = buf * */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 477, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_struct = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 248, __pyx_L1_error) - /* "View.MemoryView":480 - * cdef bytes bytesitem - * - * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<< - * try: - * result = struct.unpack(self.view.format, bytesitem) + /* "View.MemoryView":247 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf */ - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 480, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_bytesitem = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5); + __pyx_t_5 = 0; - /* "View.MemoryView":481 + /* "View.MemoryView":249 + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) + * result.data = buf # <<<<<<<<<<<<<< * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: + * return result */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_4); - /*try:*/ { + __pyx_v_result->data = __pyx_v_buf; + } + __pyx_L3:; - /* "View.MemoryView":482 - * bytesitem = itemp[:self.view.itemsize] - * try: - * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<< - * except struct.error: - * raise ValueError("Unable to convert item to object") + /* "View.MemoryView":251 + * result.data = buf + * + * return result # <<<<<<<<<<<<<< + * + * */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_8 = 1; - } - } - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); - __Pyx_INCREF(__pyx_v_bytesitem); - __Pyx_GIVEREF(__pyx_v_bytesitem); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_result = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = __pyx_v_result; + goto __pyx_L0; - /* "View.MemoryView":481 + /* "View.MemoryView":240 * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result */ - } - /* "View.MemoryView":486 - * raise ValueError("Unable to convert item to object") - * else: - * if len(self.view.format) == 1: # <<<<<<<<<<<<<< - * return result[0] - * return result - */ - /*else:*/ { - __pyx_t_10 = strlen(__pyx_v_self->view.format); - __pyx_t_11 = ((__pyx_t_10 == 1) != 0); - if (__pyx_t_11) { + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":487 - * else: - * if len(self.view.format) == 1: - * return result[0] # <<<<<<<<<<<<<< - * return result - * +/* "View.MemoryView":277 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 487, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L6_except_return; - /* "View.MemoryView":486 - * raise ValueError("Unable to convert item to object") - * else: - * if len(self.view.format) == 1: # <<<<<<<<<<<<<< - * return result[0] - * return result - */ +/* Python wrapper */ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_name = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; + PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 277, __pyx_L3_error) } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_name = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 277, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); - /* "View.MemoryView":488 - * if len(self.view.format) == 1: - * return result[0] - * return result # <<<<<<<<<<<<<< - * - * cdef assign_item_from_object(self, char *itemp, object value): + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "View.MemoryView":278 + * cdef object name + * def __init__(self, name): + * self.name = name # <<<<<<<<<<<<<< + * def __repr__(self): + * return self.name */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; - goto __pyx_L6_except_return; - } - __pyx_L3_error:; - __Pyx_PyThreadState_assign - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_INCREF(__pyx_v_name); + __Pyx_GIVEREF(__pyx_v_name); + __Pyx_GOTREF(__pyx_v_self->name); + __Pyx_DECREF(__pyx_v_self->name); + __pyx_v_self->name = __pyx_v_name; - /* "View.MemoryView":483 - * try: - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: # <<<<<<<<<<<<<< - * raise ValueError("Unable to convert item to object") - * else: + /* "View.MemoryView":277 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 483, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_12) { - __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(2, 483, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_9); - /* "View.MemoryView":484 - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< - * else: - * if len(self.view.format) == 1: + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":279 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name + * */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(2, 484, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - /* "View.MemoryView":481 +/* Python wrapper */ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "View.MemoryView":280 + * self.name = name + * def __repr__(self): + * return self.name # <<<<<<<<<<<<<< * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: + * cdef generic = Enum("") */ - __Pyx_PyThreadState_assign - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - goto __pyx_L1_error; - __pyx_L6_except_return:; - __Pyx_PyThreadState_assign - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - goto __pyx_L0; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->name); + __pyx_r = __pyx_v_self->name; + goto __pyx_L0; - /* "View.MemoryView":474 - * self.assign_item_from_object(itemp, value) + /* "View.MemoryView":279 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" */ /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_struct); - __Pyx_XDECREF(__pyx_v_bytesitem); - __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":490 - * return result +/* "View.MemoryView":294 * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory */ -static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { - PyObject *__pyx_v_struct = NULL; - char __pyx_v_c; - PyObject *__pyx_v_bytesvalue = 0; - Py_ssize_t __pyx_v_i; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - Py_ssize_t __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - char *__pyx_t_10; - char *__pyx_t_11; - char *__pyx_t_12; - char *__pyx_t_13; - __Pyx_RefNannySetupContext("assign_item_from_object", 0); - - /* "View.MemoryView":493 - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - * import struct # <<<<<<<<<<<<<< - * cdef char c - * cdef bytes bytesvalue - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_struct = __pyx_t_1; - __pyx_t_1 = 0; - - /* "View.MemoryView":498 - * cdef Py_ssize_t i - * - * if isinstance(value, tuple): # <<<<<<<<<<<<<< - * bytesvalue = struct.pack(self.view.format, *value) - * else: - */ - __pyx_t_2 = PyTuple_Check(__pyx_v_value); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { +static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) { + Py_intptr_t __pyx_v_aligned_p; + size_t __pyx_v_offset; + void *__pyx_r; + int __pyx_t_1; - /* "View.MemoryView":499 + /* "View.MemoryView":296 + * cdef void *align_pointer(void *memory, size_t alignment) nogil: + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<< + * cdef size_t offset * - * if isinstance(value, tuple): - * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<< - * else: - * bytesvalue = struct.pack(self.view.format, value) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 499, __pyx_L1_error) - __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory); - /* "View.MemoryView":498 - * cdef Py_ssize_t i + /* "View.MemoryView":300 * - * if isinstance(value, tuple): # <<<<<<<<<<<<<< - * bytesvalue = struct.pack(self.view.format, *value) - * else: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":501 - * bytesvalue = struct.pack(self.view.format, *value) - * else: - * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<< + * with cython.cdivision(True): + * offset = aligned_p % alignment # <<<<<<<<<<<<<< * - * for i, c in enumerate(bytesvalue): + * if offset > 0: */ - /*else*/ { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - __pyx_t_7 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_7 = 1; - } - } - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 501, __pyx_L1_error) - __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); - __pyx_t_4 = 0; - } - __pyx_L3:; + __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment); - /* "View.MemoryView":503 - * bytesvalue = struct.pack(self.view.format, value) + /* "View.MemoryView":302 + * offset = aligned_p % alignment * - * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< - * itemp[i] = c + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset * */ - __pyx_t_7 = 0; - if (unlikely(__pyx_v_bytesvalue == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - __PYX_ERR(2, 503, __pyx_L1_error) - } - __Pyx_INCREF(__pyx_v_bytesvalue); - __pyx_t_9 = __pyx_v_bytesvalue; - __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9); - __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9)); - for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) { - __pyx_t_10 = __pyx_t_13; - __pyx_v_c = (__pyx_t_10[0]); + __pyx_t_1 = ((__pyx_v_offset > 0) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":504 + /* "View.MemoryView":303 * - * for i, c in enumerate(bytesvalue): - * itemp[i] = c # <<<<<<<<<<<<<< + * if offset > 0: + * aligned_p += alignment - offset # <<<<<<<<<<<<<< * - * @cname('getbuffer') + * return aligned_p */ - __pyx_v_i = __pyx_t_7; + __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset)); - /* "View.MemoryView":503 - * bytesvalue = struct.pack(self.view.format, value) + /* "View.MemoryView":302 + * offset = aligned_p % alignment * - * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< - * itemp[i] = c + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset * */ - __pyx_t_7 = (__pyx_t_7 + 1); + } - /* "View.MemoryView":504 + /* "View.MemoryView":305 + * aligned_p += alignment - offset + * + * return aligned_p # <<<<<<<<<<<<<< * - * for i, c in enumerate(bytesvalue): - * itemp[i] = c # <<<<<<<<<<<<<< * - * @cname('getbuffer') */ - (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_r = ((void *)__pyx_v_aligned_p); + goto __pyx_L0; - /* "View.MemoryView":490 - * return result + /* "View.MemoryView":294 * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_struct); - __Pyx_XDECREF(__pyx_v_bytesvalue); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":507 +/* "View.MemoryView":341 + * cdef __Pyx_TypeInfo *typeinfo * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * if flags & PyBUF_STRIDES: - * info.shape = self.view.shape + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags */ /* Python wrapper */ -static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_obj = 0; + int __pyx_v_flags; + int __pyx_v_dtype_is_object; int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; - Py_ssize_t *__pyx_t_2; - char *__pyx_t_3; - void *__pyx_t_4; - int __pyx_t_5; - Py_ssize_t __pyx_t_6; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "View.MemoryView":508 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.shape = self.view.shape - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); - if (__pyx_t_1) { + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0}; + PyObject* values[3] = {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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 341, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 341, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_obj = values[0]; + __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) + if (values[2]) { + __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 341, __pyx_L3_error) + } else { + __pyx_v_dtype_is_object = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 341, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); - /* "View.MemoryView":509 - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_STRIDES: - * info.shape = self.view.shape # <<<<<<<<<<<<<< - * else: - * info.shape = NULL - */ - __pyx_t_2 = __pyx_v_self->view.shape; - __pyx_v_info->shape = __pyx_t_2; + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":508 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.shape = self.view.shape - * else: - */ - goto __pyx_L3; - } +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__cinit__", 0); - /* "View.MemoryView":511 - * info.shape = self.view.shape - * else: - * info.shape = NULL # <<<<<<<<<<<<<< + /* "View.MemoryView":342 * - * if flags & PyBUF_STRIDES: + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj # <<<<<<<<<<<<<< + * self.flags = flags + * if type(self) is memoryview or obj is not None: */ - /*else*/ { - __pyx_v_info->shape = NULL; - } - __pyx_L3:; + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + __Pyx_GOTREF(__pyx_v_self->obj); + __Pyx_DECREF(__pyx_v_self->obj); + __pyx_v_self->obj = __pyx_v_obj; - /* "View.MemoryView":513 - * info.shape = NULL - * - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.strides = self.view.strides - * else: + /* "View.MemoryView":343 + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj + * self.flags = flags # <<<<<<<<<<<<<< + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); - if (__pyx_t_1) { + __pyx_v_self->flags = __pyx_v_flags; - /* "View.MemoryView":514 - * - * if flags & PyBUF_STRIDES: - * info.strides = self.view.strides # <<<<<<<<<<<<<< - * else: - * info.strides = NULL + /* "View.MemoryView":344 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: */ - __pyx_t_2 = __pyx_v_self->view.strides; - __pyx_v_info->strides = __pyx_t_2; + __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type)); + __pyx_t_3 = (__pyx_t_2 != 0); + if (!__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_3 = (__pyx_v_obj != Py_None); + __pyx_t_2 = (__pyx_t_3 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { - /* "View.MemoryView":513 - * info.shape = NULL - * - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.strides = self.view.strides - * else: + /* "View.MemoryView":345 + * self.flags = flags + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<< + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None */ - goto __pyx_L4; - } + __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 345, __pyx_L1_error) - /* "View.MemoryView":516 - * info.strides = self.view.strides - * else: - * info.strides = NULL # <<<<<<<<<<<<<< - * - * if flags & PyBUF_INDIRECT: + /* "View.MemoryView":346 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) */ - /*else*/ { - __pyx_v_info->strides = NULL; - } - __pyx_L4:; + __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":518 - * info.strides = NULL + /* "View.MemoryView":347 + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) * - * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< - * info.suboffsets = self.view.suboffsets - * else: */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0); - if (__pyx_t_1) { + ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None; - /* "View.MemoryView":519 + /* "View.MemoryView":348 + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< * - * if flags & PyBUF_INDIRECT: - * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<< - * else: - * info.suboffsets = NULL + * global __pyx_memoryview_thread_locks_used */ - __pyx_t_2 = __pyx_v_self->view.suboffsets; - __pyx_v_info->suboffsets = __pyx_t_2; + Py_INCREF(Py_None); - /* "View.MemoryView":518 - * info.strides = NULL - * - * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< - * info.suboffsets = self.view.suboffsets - * else: + /* "View.MemoryView":346 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) */ - goto __pyx_L5; - } + } - /* "View.MemoryView":521 - * info.suboffsets = self.view.suboffsets - * else: - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * - * if flags & PyBUF_FORMAT: + /* "View.MemoryView":344 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: */ - /*else*/ { - __pyx_v_info->suboffsets = NULL; } - __pyx_L5:; - /* "View.MemoryView":523 - * info.suboffsets = NULL + /* "View.MemoryView":351 * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.view.format - * else: + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0); if (__pyx_t_1) { - /* "View.MemoryView":524 - * - * if flags & PyBUF_FORMAT: - * info.format = self.view.format # <<<<<<<<<<<<<< - * else: - * info.format = NULL + /* "View.MemoryView":352 + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: */ - __pyx_t_3 = __pyx_v_self->view.format; - __pyx_v_info->format = __pyx_t_3; + __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); - /* "View.MemoryView":523 - * info.suboffsets = NULL + /* "View.MemoryView":353 + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<< + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1); + + /* "View.MemoryView":351 * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.view.format - * else: + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 */ - goto __pyx_L6; } - /* "View.MemoryView":526 - * info.format = self.view.format - * else: - * info.format = NULL # <<<<<<<<<<<<<< + /* "View.MemoryView":354 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":355 + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<< + * if self.lock is NULL: + * raise MemoryError + */ + __pyx_v_self->lock = PyThread_allocate_lock(); + + /* "View.MemoryView":356 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError * - * info.buf = self.view.buf */ - /*else*/ { - __pyx_v_info->format = NULL; + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":357 + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + PyErr_NoMemory(); __PYX_ERR(2, 357, __pyx_L1_error) + + /* "View.MemoryView":356 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * + */ + } + + /* "View.MemoryView":354 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ } - __pyx_L6:; - /* "View.MemoryView":528 - * info.format = NULL + /* "View.MemoryView":359 + * raise MemoryError * - * info.buf = self.view.buf # <<<<<<<<<<<<<< - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: */ - __pyx_t_4 = __pyx_v_self->view.buf; - __pyx_v_info->buf = __pyx_t_4; + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":529 + /* "View.MemoryView":360 * - * info.buf = self.view.buf - * info.ndim = self.view.ndim # <<<<<<<<<<<<<< - * info.itemsize = self.view.itemsize - * info.len = self.view.len + * if flags & PyBUF_FORMAT: + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<< + * else: + * self.dtype_is_object = dtype_is_object */ - __pyx_t_5 = __pyx_v_self->view.ndim; - __pyx_v_info->ndim = __pyx_t_5; + __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_self->dtype_is_object = __pyx_t_1; - /* "View.MemoryView":530 - * info.buf = self.view.buf - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<< - * info.len = self.view.len - * info.readonly = 0 + /* "View.MemoryView":359 + * raise MemoryError + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: */ - __pyx_t_6 = __pyx_v_self->view.itemsize; - __pyx_v_info->itemsize = __pyx_t_6; + goto __pyx_L10; + } - /* "View.MemoryView":531 - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize - * info.len = self.view.len # <<<<<<<<<<<<<< - * info.readonly = 0 - * info.obj = self + /* "View.MemoryView":362 + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<< + * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( */ - __pyx_t_6 = __pyx_v_self->view.len; - __pyx_v_info->len = __pyx_t_6; + /*else*/ { + __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object; + } + __pyx_L10:; - /* "View.MemoryView":532 - * info.itemsize = self.view.itemsize - * info.len = self.view.len - * info.readonly = 0 # <<<<<<<<<<<<<< - * info.obj = self + /* "View.MemoryView":364 + * self.dtype_is_object = dtype_is_object * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<< + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL */ - __pyx_v_info->readonly = 0; + __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int)))); - /* "View.MemoryView":533 - * info.len = self.view.len - * info.readonly = 0 - * info.obj = self # <<<<<<<<<<<<<< + /* "View.MemoryView":366 + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL # <<<<<<<<<<<<<< * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + * def __dealloc__(memoryview self): */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + __pyx_v_self->typeinfo = NULL; - /* "View.MemoryView":507 + /* "View.MemoryView":341 + * cdef __Pyx_TypeInfo *typeinfo * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * if flags & PyBUF_STRIDES: - * info.shape = self.view.shape + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags */ /* function exit code */ __pyx_r = 0; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; - } + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":539 +/* "View.MemoryView":368 + * self.typeinfo = NULL * - * @property - * def T(self): # <<<<<<<<<<<<<< - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) */ /* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); - return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; - PyObject *__pyx_r = NULL; +static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("__get__", 0); + int __pyx_t_3; + int __pyx_t_4; + PyThread_type_lock __pyx_t_5; + PyThread_type_lock __pyx_t_6; + __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "View.MemoryView":540 - * @property - * def T(self): - * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<< - * transpose_memslice(&result.from_slice) - * return result + /* "View.MemoryView":369 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) + * */ - __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 540, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 540, __pyx_L1_error) - __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_1 = (__pyx_v_self->obj != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":541 - * def T(self): - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<< - * return result + /* "View.MemoryView":370 + * def __dealloc__(memoryview self): + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<< * + * cdef int i */ - __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 541, __pyx_L1_error) + __Pyx_ReleaseBuffer((&__pyx_v_self->view)); - /* "View.MemoryView":542 - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) - * return result # <<<<<<<<<<<<<< + /* "View.MemoryView":369 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) * - * @property */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; + } - /* "View.MemoryView":539 - * - * @property - * def T(self): # <<<<<<<<<<<<<< - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) + /* "View.MemoryView":374 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: */ + __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0); + if (__pyx_t_2) { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":375 + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<< + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + */ + __pyx_t_3 = __pyx_memoryview_thread_locks_used; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; -/* "View.MemoryView":545 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.obj - * + /* "View.MemoryView":376 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: */ + __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0); + if (__pyx_t_2) { -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + /* "View.MemoryView":377 + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<< + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1); - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":378 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + */ + __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0); + if (__pyx_t_2) { -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); + /* "View.MemoryView":380 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<< + * break + * else: + */ + __pyx_t_5 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_v_i]); - /* "View.MemoryView":546 - * @property - * def base(self): - * return self.obj # <<<<<<<<<<<<<< - * - * @property + /* "View.MemoryView":379 + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->obj); - __pyx_r = __pyx_v_self->obj; - goto __pyx_L0; + (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_5; + (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_6; - /* "View.MemoryView":545 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.obj - * + /* "View.MemoryView":378 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) */ + } - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":381 + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break # <<<<<<<<<<<<<< + * else: + * PyThread_free_lock(self.lock) + */ + goto __pyx_L6_break; -/* "View.MemoryView":549 - * - * @property - * def shape(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) + /* "View.MemoryView":376 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + */ + } + } + /*else*/ { + + /* "View.MemoryView":383 + * break + * else: + * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<< * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: */ + PyThread_free_lock(__pyx_v_self->lock); + } + __pyx_L6_break:; -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + /* "View.MemoryView":374 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + */ + } + + /* "View.MemoryView":368 + * self.typeinfo = NULL + * + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + */ /* function exit code */ __Pyx_RefNannyFinishContext(); - return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_length; - PyObject *__pyx_r = NULL; +/* "View.MemoryView":385 + * PyThread_free_lock(self.lock) + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf + */ + +static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + Py_ssize_t __pyx_v_dim; + char *__pyx_v_itemp; + PyObject *__pyx_v_idx = NULL; + char *__pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); + Py_ssize_t __pyx_t_6; + char *__pyx_t_7; + __Pyx_RefNannySetupContext("get_item_pointer", 0); - /* "View.MemoryView":550 - * @property - * def shape(self): - * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< + /* "View.MemoryView":387 + * cdef char *get_item_pointer(memoryview self, object index) except NULL: + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<< * - * @property + * for dim, idx in enumerate(index): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 550, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { - __pyx_t_2 = __pyx_t_4; - __pyx_v_length = (__pyx_t_2[0]); - __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 550, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; + __pyx_v_itemp = ((char *)__pyx_v_self->view.buf); - /* "View.MemoryView":549 + /* "View.MemoryView":389 + * cdef char *itemp = self.view.buf * - * @property - * def shape(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) * */ + __pyx_t_1 = 0; + if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) { + __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 389, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 389, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_v_dim = __pyx_t_1; + __pyx_t_1 = (__pyx_t_1 + 1); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":553 - * - * @property - * def strides(self): # <<<<<<<<<<<<<< - * if self.view.strides == NULL: + /* "View.MemoryView":390 * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_stride; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":554 - * @property - * def strides(self): - * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * for dim, idx in enumerate(index): + * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<< * - * raise ValueError("Buffer view does not expose strides") + * return itemp */ - __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0); - if (__pyx_t_1) { + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 390, __pyx_L1_error) + __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(2, 390, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_7; - /* "View.MemoryView":556 - * if self.view.strides == NULL: - * - * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + /* "View.MemoryView":389 + * cdef char *itemp = self.view.buf * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(2, 556, __pyx_L1_error) - - /* "View.MemoryView":554 - * @property - * def strides(self): - * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) * - * raise ValueError("Buffer view does not expose strides") */ } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "View.MemoryView":558 - * raise ValueError("Buffer view does not expose strides") + /* "View.MemoryView":392 + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + * return itemp # <<<<<<<<<<<<<< * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< * - * @property */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 558, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_v_stride = (__pyx_t_3[0]); - __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 558, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; + __pyx_r = __pyx_v_itemp; goto __pyx_L0; - /* "View.MemoryView":553 - * - * @property - * def strides(self): # <<<<<<<<<<<<<< - * if self.view.strides == NULL: + /* "View.MemoryView":385 + * PyThread_free_lock(self.lock) * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); + __Pyx_XDECREF(__pyx_v_idx); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":561 +/* "View.MemoryView":395 * - * @property - * def suboffsets(self): # <<<<<<<<<<<<<< - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim + * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self */ /* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_suboffset; +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_indices = NULL; + char *__pyx_v_itemp; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - Py_ssize_t *__pyx_t_6; - __Pyx_RefNannySetupContext("__get__", 0); + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + char *__pyx_t_6; + __Pyx_RefNannySetupContext("__getitem__", 0); - /* "View.MemoryView":562 - * @property - * def suboffsets(self): - * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< - * return (-1,) * self.view.ndim + /* "View.MemoryView":396 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self * */ - __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); - if (__pyx_t_1) { + __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":563 - * def suboffsets(self): - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + /* "View.MemoryView":397 + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: + * return self # <<<<<<<<<<<<<< * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + * have_slices, indices = _unellipsify(index, self.view.ndim) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__18, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; - /* "View.MemoryView":562 - * @property - * def suboffsets(self): - * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< - * return (-1,) * self.view.ndim + /* "View.MemoryView":396 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self * */ } - /* "View.MemoryView":565 - * return (-1,) * self.view.ndim + /* "View.MemoryView":399 + * return self * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< + * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< * - * @property + * cdef char *itemp */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 565, __pyx_L1_error) + __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); - for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { - __pyx_t_4 = __pyx_t_6; - __pyx_v_suboffset = (__pyx_t_4[0]); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 565, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (likely(__pyx_t_3 != Py_None)) { + PyObject* sequence = __pyx_t_3; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(2, 399, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + #else + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 399, __pyx_L1_error) } - __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __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; - goto __pyx_L0; + __pyx_v_have_slices = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_v_indices = __pyx_t_5; + __pyx_t_5 = 0; - /* "View.MemoryView":561 + /* "View.MemoryView":402 * - * @property - * def suboffsets(self): # <<<<<<<<<<<<<< - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: */ + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 402, __pyx_L1_error) + if (__pyx_t_2) { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":403 + * cdef char *itemp + * if have_slices: + * return memview_slice(self, indices) # <<<<<<<<<<<<<< + * else: + * itemp = self.get_item_pointer(indices) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; -/* "View.MemoryView":568 - * - * @property - * def ndim(self): # <<<<<<<<<<<<<< - * return self.view.ndim + /* "View.MemoryView":402 * + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: */ + } -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); + /* "View.MemoryView":405 + * return memview_slice(self, indices) + * else: + * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<< + * return self.convert_item_to_object(itemp) + * + */ + /*else*/ { + __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 405, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_6; - /* "View.MemoryView":569 - * @property - * def ndim(self): - * return self.view.ndim # <<<<<<<<<<<<<< + /* "View.MemoryView":406 + * else: + * itemp = self.get_item_pointer(indices) + * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<< * - * @property + * def __setitem__(memoryview self, object index, object value): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 569, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 406, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + } - /* "View.MemoryView":568 + /* "View.MemoryView":395 * - * @property - * def ndim(self): # <<<<<<<<<<<<<< - * return self.view.ndim * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_indices); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":572 +/* "View.MemoryView":408 + * return self.convert_item_to_object(itemp) * - * @property - * def itemsize(self): # <<<<<<<<<<<<<< - * return self.view.itemsize + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * have_slices, index = _unellipsify(index, self.view.ndim) * */ /* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_obj = NULL; + int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__setitem__", 0); + __Pyx_INCREF(__pyx_v_index); - /* "View.MemoryView":573 - * @property - * def itemsize(self): - * return self.view.itemsize # <<<<<<<<<<<<<< + /* "View.MemoryView":409 * - * @property + * def __setitem__(memoryview self, object index, object value): + * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + * + * if have_slices: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 573, __pyx_L1_error) + __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + if (likely(__pyx_t_1 != Py_None)) { + PyObject* sequence = __pyx_t_1; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(2, 409, __pyx_L1_error) + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + #else + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 409, __pyx_L1_error) + } + __pyx_v_have_slices = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3); + __pyx_t_3 = 0; - /* "View.MemoryView":572 + /* "View.MemoryView":411 + * have_slices, index = _unellipsify(index, self.view.ndim) * - * @property - * def itemsize(self): # <<<<<<<<<<<<<< - * return self.view.itemsize + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 411, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":412 * + * if have_slices: + * obj = self.is_slice(value) # <<<<<<<<<<<<<< + * if obj: + * self.setitem_slice_assignment(self[index], obj) */ + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 412, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_obj = __pyx_t_1; + __pyx_t_1 = 0; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":413 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 413, __pyx_L1_error) + if (__pyx_t_4) { -/* "View.MemoryView":576 - * - * @property - * def nbytes(self): # <<<<<<<<<<<<<< - * return self.size * self.view.itemsize - * + /* "View.MemoryView":414 + * obj = self.is_slice(value) + * if obj: + * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<< + * else: + * self.setitem_slice_assign_scalar(self[index], value) */ + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 414, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 414, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + /* "View.MemoryView":413 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + goto __pyx_L4; + } - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":416 + * self.setitem_slice_assignment(self[index], obj) + * else: + * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<< + * else: + * self.setitem_indexed(index, value) + */ + /*else*/ { + __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 416, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 416, __pyx_L1_error) + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 416, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L4:; -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); + /* "View.MemoryView":411 + * have_slices, index = _unellipsify(index, self.view.ndim) + * + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + goto __pyx_L3; + } - /* "View.MemoryView":577 - * @property - * def nbytes(self): - * return self.size * self.view.itemsize # <<<<<<<<<<<<<< + /* "View.MemoryView":418 + * self.setitem_slice_assign_scalar(self[index], value) + * else: + * self.setitem_indexed(index, value) # <<<<<<<<<<<<<< * - * @property + * cdef is_slice(self, obj): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + /*else*/ { + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 418, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L3:; - /* "View.MemoryView":576 + /* "View.MemoryView":408 + * return self.convert_item_to_object(itemp) * - * @property - * def nbytes(self): # <<<<<<<<<<<<<< - * return self.size * self.view.itemsize + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * have_slices, index = _unellipsify(index, self.view.ndim) * */ /* 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_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_obj); + __Pyx_XDECREF(__pyx_v_index); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":580 +/* "View.MemoryView":420 + * self.setitem_indexed(index, value) * - * @property - * def size(self): # <<<<<<<<<<<<<< - * if self._size is None: - * result = 1 + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: */ -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_v_length = NULL; +static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + __Pyx_RefNannySetupContext("is_slice", 0); + __Pyx_INCREF(__pyx_v_obj); - /* "View.MemoryView":581 - * @property - * def size(self): - * if self._size is None: # <<<<<<<<<<<<<< - * result = 1 + /* "View.MemoryView":421 * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, */ - __pyx_t_1 = (__pyx_v_self->_size == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":582 - * def size(self): - * if self._size is None: - * result = 1 # <<<<<<<<<<<<<< - * - * for length in self.view.shape[:self.view.ndim]: + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) */ - __Pyx_INCREF(__pyx_int_1); - __pyx_v_result = __pyx_int_1; + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + /*try:*/ { - /* "View.MemoryView":584 - * result = 1 - * - * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< - * result *= length - * + /* "View.MemoryView":423 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: */ - __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 584, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); - __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_6); - /* "View.MemoryView":585 - * - * for length in self.view.shape[:self.view.ndim]: - * result *= length # <<<<<<<<<<<<<< - * - * self._size = result + /* "View.MemoryView":424 + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) # <<<<<<<<<<<<<< + * except TypeError: + * return None */ - __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 585, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); - __pyx_t_6 = 0; - } + __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 424, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); - /* "View.MemoryView":587 - * result *= length + /* "View.MemoryView":423 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: + */ + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 423, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7); + __pyx_t_7 = 0; + + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + } + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L11_try_end; + __pyx_L4_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "View.MemoryView":425 + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + * except TypeError: # <<<<<<<<<<<<<< + * return None * - * self._size = result # <<<<<<<<<<<<<< + */ + __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); + if (__pyx_t_9) { + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 425, __pyx_L6_except_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GOTREF(__pyx_t_6); + + /* "View.MemoryView":426 + * self.dtype_is_object) + * except TypeError: + * return None # <<<<<<<<<<<<<< * - * return self._size + * return obj */ - __Pyx_INCREF(__pyx_v_result); - __Pyx_GIVEREF(__pyx_v_result); - __Pyx_GOTREF(__pyx_v_self->_size); - __Pyx_DECREF(__pyx_v_self->_size); - __pyx_v_self->_size = __pyx_v_result; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L7_except_return; + } + goto __pyx_L6_except_error; + __pyx_L6_except_error:; - /* "View.MemoryView":581 - * @property - * def size(self): - * if self._size is None: # <<<<<<<<<<<<<< - * result = 1 + /* "View.MemoryView":422 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L1_error; + __pyx_L7_except_return:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L0; + __pyx_L11_try_end:; + } + + /* "View.MemoryView":421 * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, */ } - /* "View.MemoryView":589 - * self._size = result + /* "View.MemoryView":428 + * return None * - * return self._size # <<<<<<<<<<<<<< + * return obj # <<<<<<<<<<<<<< * - * def __len__(self): + * cdef setitem_slice_assignment(self, dst, src): */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->_size); - __pyx_r = __pyx_v_self->_size; + __Pyx_INCREF(__pyx_v_obj); + __pyx_r = __pyx_v_obj; goto __pyx_L0; - /* "View.MemoryView":580 + /* "View.MemoryView":420 + * self.setitem_indexed(index, value) * - * @property - * def size(self): # <<<<<<<<<<<<<< - * if self._size is None: - * result = 1 + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_length); + __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":591 - * return self._size +/* "View.MemoryView":430 + * return obj * - * def __len__(self): # <<<<<<<<<<<<<< - * if self.view.ndim >= 1: - * return self.view.shape[0] + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice */ -/* Python wrapper */ -static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/ -static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { - Py_ssize_t __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_r; +static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) { + __Pyx_memviewslice __pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_src_slice; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__len__", 0); + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("setitem_slice_assignment", 0); - /* "View.MemoryView":592 - * - * def __len__(self): - * if self.view.ndim >= 1: # <<<<<<<<<<<<<< - * return self.view.shape[0] + /* "View.MemoryView":434 + * cdef __Pyx_memviewslice src_slice * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) */ - __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0); - if (__pyx_t_1) { + if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 434, __pyx_L1_error) - /* "View.MemoryView":593 - * def __len__(self): - * if self.view.ndim >= 1: - * return self.view.shape[0] # <<<<<<<<<<<<<< + /* "View.MemoryView":435 + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<< + * src.ndim, dst.ndim, self.dtype_is_object) * - * return 0 */ - __pyx_r = (__pyx_v_self->view.shape[0]); - goto __pyx_L0; + if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 435, __pyx_L1_error) - /* "View.MemoryView":592 - * - * def __len__(self): - * if self.view.ndim >= 1: # <<<<<<<<<<<<<< - * return self.view.shape[0] + /* "View.MemoryView":436 + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<< * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): */ - } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 436, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "View.MemoryView":595 - * return self.view.shape[0] - * - * return 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":434 + * cdef __Pyx_memviewslice src_slice * - * def __repr__(self): + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) */ - __pyx_r = 0; - goto __pyx_L0; + __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 434, __pyx_L1_error) - /* "View.MemoryView":591 - * return self._size + /* "View.MemoryView":430 + * return obj * - * def __len__(self): # <<<<<<<<<<<<<< - * if self.view.ndim >= 1: - * return self.view.shape[0] + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":597 - * return 0 +/* "View.MemoryView":438 + * src.ndim, dst.ndim, self.dtype_is_object) * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__, - * id(self)) + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL */ -/* Python wrapper */ -static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { + int __pyx_v_array[0x80]; + void *__pyx_v_tmp; + void *__pyx_v_item; + __Pyx_memviewslice *__pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_tmp_slice; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("__repr__", 0); + int __pyx_t_3; + int __pyx_t_4; + char const *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0); - /* "View.MemoryView":598 - * - * def __repr__(self): - * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< - * id(self)) + /* "View.MemoryView":440 + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + * cdef int array[128] + * cdef void *tmp = NULL # <<<<<<<<<<<<<< + * cdef void *item * */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_tmp = NULL; - /* "View.MemoryView":599 - * def __repr__(self): - * return "" % (self.base.__class__.__name__, - * id(self)) # <<<<<<<<<<<<<< + /* "View.MemoryView":445 + * cdef __Pyx_memviewslice *dst_slice + * cdef __Pyx_memviewslice tmp_slice + * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<< * - * def __str__(self): + * if self.view.itemsize > sizeof(array): */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 599, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 599, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); - /* "View.MemoryView":598 - * - * def __repr__(self): - * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< - * id(self)) + /* "View.MemoryView":447 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); - __pyx_t_1 = 0; - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; + __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":597 - * return 0 + /* "View.MemoryView":448 * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__, - * id(self)) + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<< + * if tmp == NULL: + * raise MemoryError */ + __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":601 - * id(self)) - * - * def __str__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__,) - * + /* "View.MemoryView":449 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp */ + __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0); + if (__pyx_t_1) { -/* Python wrapper */ -static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + /* "View.MemoryView":450 + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * item = tmp + * else: + */ + PyErr_NoMemory(); __PYX_ERR(2, 450, __pyx_L1_error) - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":449 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp + */ + } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__str__", 0); + /* "View.MemoryView":451 + * if tmp == NULL: + * raise MemoryError + * item = tmp # <<<<<<<<<<<<<< + * else: + * item = array + */ + __pyx_v_item = __pyx_v_tmp; - /* "View.MemoryView":602 - * - * def __str__(self): - * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":447 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + goto __pyx_L3; + } - /* "View.MemoryView":601 - * id(self)) - * - * def __str__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__,) + /* "View.MemoryView":453 + * item = tmp + * else: + * item = array # <<<<<<<<<<<<<< * + * try: */ + /*else*/ { + __pyx_v_item = ((void *)__pyx_v_array); + } + __pyx_L3:; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":605 - * + /* "View.MemoryView":455 + * item = array * - * def is_c_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp + * try: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * ( item)[0] = value */ + /*try:*/ { -/* Python wrapper */ -static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":456 + * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: + */ + __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_1) { -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice *__pyx_v_mslice; - __Pyx_memviewslice __pyx_v_tmp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("is_c_contig", 0); + /* "View.MemoryView":457 + * try: + * if self.dtype_is_object: + * ( item)[0] = value # <<<<<<<<<<<<<< + * else: + * self.assign_item_from_object( item, value) + */ + (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value); - /* "View.MemoryView":608 - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< - * return slice_is_contig(mslice[0], 'C', self.view.ndim) + /* "View.MemoryView":456 * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: */ - __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); + goto __pyx_L8; + } - /* "View.MemoryView":609 - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) - * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<< + /* "View.MemoryView":459 + * ( item)[0] = value + * else: + * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<< + * * - * def is_f_contig(self): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 609, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + /*else*/ { + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 459, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_L8:; - /* "View.MemoryView":605 + /* "View.MemoryView":463 * * - * def is_c_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, */ + __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0); + if (__pyx_t_1) { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":611 - * return slice_is_contig(mslice[0], 'C', self.view.ndim) + /* "View.MemoryView":464 * - * def is_f_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<< + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + * item, self.dtype_is_object) */ + __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 464, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; -/* Python wrapper */ -static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice *__pyx_v_mslice; - __Pyx_memviewslice __pyx_v_tmp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("is_f_contig", 0); - - /* "View.MemoryView":614 - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< - * return slice_is_contig(mslice[0], 'F', self.view.ndim) + /* "View.MemoryView":463 + * * + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, */ - __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); + } - /* "View.MemoryView":615 - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) - * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<< + /* "View.MemoryView":465 + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<< + * item, self.dtype_is_object) + * finally: + */ + __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object); + } + + /* "View.MemoryView":468 + * item, self.dtype_is_object) + * finally: + * PyMem_Free(tmp) # <<<<<<<<<<<<<< * - * def copy(self): + * cdef setitem_indexed(self, index, value): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 615, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + /*finally:*/ { + /*normal exit:*/{ + PyMem_Free(__pyx_v_tmp); + goto __pyx_L7; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L6_error:; + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename; + { + PyMem_Free(__pyx_v_tmp); + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); + } + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8); + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; + __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5; + goto __pyx_L1_error; + } + __pyx_L7:; + } - /* "View.MemoryView":611 - * return slice_is_contig(mslice[0], 'C', self.view.ndim) + /* "View.MemoryView":438 + * src.ndim, dst.ndim, self.dtype_is_object) * - * def is_f_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":617 - * return slice_is_contig(mslice[0], 'F', self.view.ndim) +/* "View.MemoryView":470 + * PyMem_Free(tmp) * - * def copy(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) */ -/* Python wrapper */ -static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; +static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + char *__pyx_v_itemp; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("copy (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice __pyx_v_mslice; - int __pyx_v_flags; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice __pyx_t_1; + char *__pyx_t_1; PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("copy", 0); - - /* "View.MemoryView":619 - * def copy(self): - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<< - * - * slice_copy(self, &mslice) - */ - __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS)); + __Pyx_RefNannySetupContext("setitem_indexed", 0); - /* "View.MemoryView":621 - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + /* "View.MemoryView":471 * - * slice_copy(self, &mslice) # <<<<<<<<<<<<<< - * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, - * self.view.itemsize, - */ - __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice)); - - /* "View.MemoryView":622 + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<< + * self.assign_item_from_object(itemp, value) * - * slice_copy(self, &mslice) - * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<< - * self.view.itemsize, - * flags|PyBUF_C_CONTIGUOUS, */ - __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 622, __pyx_L1_error) - __pyx_v_mslice = __pyx_t_1; + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(2, 471, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_1; - /* "View.MemoryView":627 - * self.dtype_is_object) - * - * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<< + /* "View.MemoryView":472 + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<< * - * def copy_fortran(self): + * cdef convert_item_to_object(self, char *itemp): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 627, __pyx_L1_error) + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "View.MemoryView":617 - * return slice_is_contig(mslice[0], 'F', self.view.ndim) + /* "View.MemoryView":470 + * PyMem_Free(tmp) * - * def copy(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":629 - * return memoryview_copy_from_slice(self, &mslice) +/* "View.MemoryView":474 + * self.assign_item_from_object(itemp, value) * - * def copy_fortran(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" */ -/* Python wrapper */ -static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice __pyx_v_src; - __Pyx_memviewslice __pyx_v_dst; - int __pyx_v_flags; +static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_v_struct = NULL; + PyObject *__pyx_v_bytesitem = 0; + PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("copy_fortran", 0); - - /* "View.MemoryView":631 - * def copy_fortran(self): - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<< - * - * slice_copy(self, &src) - */ - __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS)); + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + size_t __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + __Pyx_RefNannySetupContext("convert_item_to_object", 0); - /* "View.MemoryView":633 - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + /* "View.MemoryView":477 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef bytes bytesitem * - * slice_copy(self, &src) # <<<<<<<<<<<<<< - * dst = slice_copy_contig(&src, "fortran", self.view.ndim, - * self.view.itemsize, */ - __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src)); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 477, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; - /* "View.MemoryView":634 + /* "View.MemoryView":480 + * cdef bytes bytesitem * - * slice_copy(self, &src) - * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<< - * self.view.itemsize, - * flags|PyBUF_F_CONTIGUOUS, + * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<< + * try: + * result = struct.unpack(self.view.format, bytesitem) */ - __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 634, __pyx_L1_error) - __pyx_v_dst = __pyx_t_1; + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 480, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_bytesitem = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; - /* "View.MemoryView":639 - * self.dtype_is_object) - * - * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":481 * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 639, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + /*try:*/ { - /* "View.MemoryView":629 - * return memoryview_copy_from_slice(self, &mslice) - * - * def copy_fortran(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + /* "View.MemoryView":482 + * bytesitem = itemp[:self.view.itemsize] + * try: + * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<< + * except struct.error: + * raise ValueError("Unable to convert item to object") */ + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_8 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); + __Pyx_INCREF(__pyx_v_bytesitem); + __Pyx_GIVEREF(__pyx_v_bytesitem); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = __pyx_t_1; + __pyx_t_1 = 0; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":643 + /* "View.MemoryView":481 * - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: */ + } -static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) { - struct __pyx_memoryview_obj *__pyx_v_result = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("memoryview_cwrapper", 0); + /* "View.MemoryView":486 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + /*else:*/ { + __pyx_t_10 = strlen(__pyx_v_self->view.format); + __pyx_t_11 = ((__pyx_t_10 == 1) != 0); + if (__pyx_t_11) { - /* "View.MemoryView":644 - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): - * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<< - * result.typeinfo = typeinfo - * return result + /* "View.MemoryView":487 + * else: + * if len(self.view.format) == 1: + * return result[0] # <<<<<<<<<<<<<< + * return result + * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 644, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 644, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2); - __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 487, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L6_except_return; - /* "View.MemoryView":645 - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo # <<<<<<<<<<<<<< - * return result + /* "View.MemoryView":486 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + } + + /* "View.MemoryView":488 + * if len(self.view.format) == 1: + * return result[0] + * return result # <<<<<<<<<<<<<< * + * cdef assign_item_from_object(self, char *itemp, object value): */ - __pyx_v_result->typeinfo = __pyx_v_typeinfo; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L6_except_return; + } + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "View.MemoryView":646 - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo - * return result # <<<<<<<<<<<<<< + /* "View.MemoryView":483 + * try: + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: # <<<<<<<<<<<<<< + * raise ValueError("Unable to convert item to object") + * else: + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 483, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_12) { + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(2, 483, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_9); + + /* "View.MemoryView":484 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(2, 484, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "View.MemoryView":481 * - * @cname('__pyx_memoryview_check') + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L1_error; + __pyx_L6_except_return:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L0; + } - /* "View.MemoryView":643 + /* "View.MemoryView":474 + * self.assign_item_from_object(itemp, value) * - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesitem); + __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":649 - * - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< - * return isinstance(o, memoryview) +/* "View.MemoryView":490 + * return result * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" */ -static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) { - int __pyx_r; +static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_v_struct = NULL; + char __pyx_v_c; + PyObject *__pyx_v_bytesvalue = 0; + Py_ssize_t __pyx_v_i; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("memoryview_check", 0); + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + char *__pyx_t_10; + char *__pyx_t_11; + char *__pyx_t_12; + char *__pyx_t_13; + __Pyx_RefNannySetupContext("assign_item_from_object", 0); - /* "View.MemoryView":650 - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): - * return isinstance(o, memoryview) # <<<<<<<<<<<<<< - * - * cdef tuple _unellipsify(object index, int ndim): + /* "View.MemoryView":493 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef char c + * cdef bytes bytesvalue */ - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); - __pyx_r = __pyx_t_1; - goto __pyx_L0; + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; - /* "View.MemoryView":649 - * - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< - * return isinstance(o, memoryview) + /* "View.MemoryView":498 + * cdef Py_ssize_t i * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: */ + __pyx_t_2 = PyTuple_Check(__pyx_v_value); + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":652 - * return isinstance(o, memoryview) + /* "View.MemoryView":499 * - * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< - * """ - * Replace all ellipses with full slices and fill incomplete indices with + * if isinstance(value, tuple): + * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<< + * else: + * bytesvalue = struct.pack(self.view.format, value) */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 499, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 499, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; -static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { - PyObject *__pyx_v_tup = NULL; - PyObject *__pyx_v_result = NULL; - int __pyx_v_have_slices; - int __pyx_v_seen_ellipsis; - CYTHON_UNUSED PyObject *__pyx_v_idx = NULL; - PyObject *__pyx_v_item = NULL; - Py_ssize_t __pyx_v_nslices; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; - PyObject *(*__pyx_t_6)(PyObject *); - PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - PyObject *__pyx_t_11 = NULL; - __Pyx_RefNannySetupContext("_unellipsify", 0); - - /* "View.MemoryView":657 - * full slices. - * """ - * if not isinstance(index, tuple): # <<<<<<<<<<<<<< - * tup = (index,) - * else: - */ - __pyx_t_1 = PyTuple_Check(__pyx_v_index); - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":658 - * """ - * if not isinstance(index, tuple): - * tup = (index,) # <<<<<<<<<<<<<< - * else: - * tup = index - */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_index); - __Pyx_GIVEREF(__pyx_v_index); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index); - __pyx_v_tup = __pyx_t_3; - __pyx_t_3 = 0; - - /* "View.MemoryView":657 - * full slices. - * """ - * if not isinstance(index, tuple): # <<<<<<<<<<<<<< - * tup = (index,) - * else: + /* "View.MemoryView":498 + * cdef Py_ssize_t i + * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: */ goto __pyx_L3; } - /* "View.MemoryView":660 - * tup = (index,) - * else: - * tup = index # <<<<<<<<<<<<<< + /* "View.MemoryView":501 + * bytesvalue = struct.pack(self.view.format, *value) + * else: + * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<< * - * result = [] + * for i, c in enumerate(bytesvalue): */ /*else*/ { - __Pyx_INCREF(__pyx_v_index); - __pyx_v_tup = __pyx_v_index; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_7 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_7 = 1; + } + } + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 501, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; } __pyx_L3:; - /* "View.MemoryView":662 - * tup = index + /* "View.MemoryView":503 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c * - * result = [] # <<<<<<<<<<<<<< - * have_slices = False - * seen_ellipsis = False */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 662, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_v_result = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_7 = 0; + if (unlikely(__pyx_v_bytesvalue == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); + __PYX_ERR(2, 503, __pyx_L1_error) + } + __Pyx_INCREF(__pyx_v_bytesvalue); + __pyx_t_9 = __pyx_v_bytesvalue; + __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9); + __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9)); + for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) { + __pyx_t_10 = __pyx_t_13; + __pyx_v_c = (__pyx_t_10[0]); - /* "View.MemoryView":663 + /* "View.MemoryView":504 * - * result = [] - * have_slices = False # <<<<<<<<<<<<<< - * seen_ellipsis = False - * for idx, item in enumerate(tup): + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') */ - __pyx_v_have_slices = 0; + __pyx_v_i = __pyx_t_7; - /* "View.MemoryView":664 - * result = [] - * have_slices = False - * seen_ellipsis = False # <<<<<<<<<<<<<< - * for idx, item in enumerate(tup): - * if item is Ellipsis: + /* "View.MemoryView":503 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c + * */ - __pyx_v_seen_ellipsis = 0; + __pyx_t_7 = (__pyx_t_7 + 1); - /* "View.MemoryView":665 - * have_slices = False - * seen_ellipsis = False - * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< - * if item is Ellipsis: - * if not seen_ellipsis: + /* "View.MemoryView":504 + * + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') */ - __Pyx_INCREF(__pyx_int_0); - __pyx_t_3 = __pyx_int_0; - if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) { - __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; - __pyx_t_6 = NULL; - } else { - __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 665, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 665, __pyx_L1_error) + (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; } - for (;;) { - if (likely(!__pyx_t_6)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) - #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - } else { - if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) - #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - } - } else { - __pyx_t_7 = __pyx_t_6(__pyx_t_4); - if (unlikely(!__pyx_t_7)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(2, 665, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_7); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); - __pyx_t_7 = 0; - __Pyx_INCREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3); - __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_7; - __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "View.MemoryView":666 - * seen_ellipsis = False - * for idx, item in enumerate(tup): - * if item is Ellipsis: # <<<<<<<<<<<<<< - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) + /* "View.MemoryView":490 + * return result + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" */ - __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - /* "View.MemoryView":667 - * for idx, item in enumerate(tup): - * if item is Ellipsis: - * if not seen_ellipsis: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True - */ - __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0); - if (__pyx_t_1) { + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesvalue); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":668 - * if item is Ellipsis: - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< - * seen_ellipsis = True - * else: +/* "View.MemoryView":507 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape */ - __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) - __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__19); - __Pyx_GIVEREF(__pyx_slice__19); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__19); - } - } - __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "View.MemoryView":669 - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True # <<<<<<<<<<<<<< - * else: - * result.append(slice(None)) - */ - __pyx_v_seen_ellipsis = 1; +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - /* "View.MemoryView":667 - * for idx, item in enumerate(tup): - * if item is Ellipsis: - * if not seen_ellipsis: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True - */ - goto __pyx_L7; - } + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":671 - * seen_ellipsis = True - * else: - * result.append(slice(None)) # <<<<<<<<<<<<<< - * have_slices = True - * else: - */ - /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__20); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) - } - __pyx_L7:; +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + Py_ssize_t *__pyx_t_2; + char *__pyx_t_3; + void *__pyx_t_4; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } - /* "View.MemoryView":672 - * else: - * result.append(slice(None)) - * have_slices = True # <<<<<<<<<<<<<< + /* "View.MemoryView":508 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.shape = self.view.shape * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): */ - __pyx_v_have_slices = 1; - - /* "View.MemoryView":666 - * seen_ellipsis = False - * for idx, item in enumerate(tup): - * if item is Ellipsis: # <<<<<<<<<<<<<< - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - */ - goto __pyx_L6; - } + __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":674 - * have_slices = True + /* "View.MemoryView":509 + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape # <<<<<<<<<<<<<< * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< - * raise TypeError("Cannot index with type '%s'" % type(item)) - * + * info.shape = NULL */ - /*else*/ { - __pyx_t_2 = PySlice_Check(__pyx_v_item); - __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); - if (__pyx_t_10) { - } else { - __pyx_t_1 = __pyx_t_10; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); - __pyx_t_1 = __pyx_t_10; - __pyx_L9_bool_binop_done:; - if (__pyx_t_1) { + __pyx_t_2 = __pyx_v_self->view.shape; + __pyx_v_info->shape = __pyx_t_2; - /* "View.MemoryView":675 + /* "View.MemoryView":508 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.shape = self.view.shape * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): - * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<< - * - * have_slices = have_slices or isinstance(item, slice) */ - __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_Raise(__pyx_t_7, 0, 0, 0); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(2, 675, __pyx_L1_error) + goto __pyx_L3; + } - /* "View.MemoryView":674 - * have_slices = True + /* "View.MemoryView":511 + * info.shape = self.view.shape * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< - * raise TypeError("Cannot index with type '%s'" % type(item)) + * info.shape = NULL # <<<<<<<<<<<<<< * + * if flags & PyBUF_STRIDES: */ - } + /*else*/ { + __pyx_v_info->shape = NULL; + } + __pyx_L3:; - /* "View.MemoryView":677 - * raise TypeError("Cannot index with type '%s'" % type(item)) - * - * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<< - * result.append(item) + /* "View.MemoryView":513 + * info.shape = NULL * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: */ - __pyx_t_10 = (__pyx_v_have_slices != 0); - if (!__pyx_t_10) { - } else { - __pyx_t_1 = __pyx_t_10; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_10 = PySlice_Check(__pyx_v_item); - __pyx_t_2 = (__pyx_t_10 != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L11_bool_binop_done:; - __pyx_v_have_slices = __pyx_t_1; + __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":678 - * - * have_slices = have_slices or isinstance(item, slice) - * result.append(item) # <<<<<<<<<<<<<< + /* "View.MemoryView":514 * - * nslices = ndim - len(result) + * if flags & PyBUF_STRIDES: + * info.strides = self.view.strides # <<<<<<<<<<<<<< + * else: + * info.strides = NULL */ - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 678, __pyx_L1_error) - } - __pyx_L6:; + __pyx_t_2 = __pyx_v_self->view.strides; + __pyx_v_info->strides = __pyx_t_2; - /* "View.MemoryView":665 - * have_slices = False - * seen_ellipsis = False - * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< - * if item is Ellipsis: - * if not seen_ellipsis: + /* "View.MemoryView":513 + * info.shape = NULL + * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: */ + goto __pyx_L4; } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":680 - * result.append(item) + /* "View.MemoryView":516 + * info.strides = self.view.strides + * else: + * info.strides = NULL # <<<<<<<<<<<<<< * - * nslices = ndim - len(result) # <<<<<<<<<<<<<< - * if nslices: - * result.extend([slice(None)] * nslices) + * if flags & PyBUF_INDIRECT: */ - __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(2, 680, __pyx_L1_error) - __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5); + /*else*/ { + __pyx_v_info->strides = NULL; + } + __pyx_L4:; - /* "View.MemoryView":681 - * - * nslices = ndim - len(result) - * if nslices: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * nslices) + /* "View.MemoryView":518 + * info.strides = NULL * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: */ - __pyx_t_1 = (__pyx_v_nslices != 0); + __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0); if (__pyx_t_1) { - /* "View.MemoryView":682 - * nslices = ndim - len(result) - * if nslices: - * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + /* "View.MemoryView":519 * - * return have_slices or nslices, tuple(result) + * if flags & PyBUF_INDIRECT: + * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<< + * else: + * info.suboffsets = NULL */ - __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__21); - __Pyx_GIVEREF(__pyx_slice__21); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__21); - } - } - __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = __pyx_v_self->view.suboffsets; + __pyx_v_info->suboffsets = __pyx_t_2; - /* "View.MemoryView":681 - * - * nslices = ndim - len(result) - * if nslices: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * nslices) + /* "View.MemoryView":518 + * info.strides = NULL * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: */ + goto __pyx_L5; } - /* "View.MemoryView":684 - * result.extend([slice(None)] * nslices) - * - * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<< + /* "View.MemoryView":521 + * info.suboffsets = self.view.suboffsets + * else: + * info.suboffsets = NULL # <<<<<<<<<<<<<< * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * if flags & PyBUF_FORMAT: */ - __Pyx_XDECREF(__pyx_r); - if (!__pyx_v_have_slices) { - } else { - __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L14_bool_binop_done; + /*else*/ { + __pyx_v_info->suboffsets = NULL; } - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_L14_bool_binop_done:; - __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 684, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_r = ((PyObject*)__pyx_t_7); - __pyx_t_7 = 0; - goto __pyx_L0; + __pyx_L5:; - /* "View.MemoryView":652 - * return isinstance(o, memoryview) + /* "View.MemoryView":523 + * info.suboffsets = NULL * - * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< - * """ - * Replace all ellipses with full slices and fill incomplete indices with + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_tup); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_idx); - __Pyx_XDECREF(__pyx_v_item); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":686 - * return have_slices or nslices, tuple(result) + /* "View.MemoryView":524 * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + * if flags & PyBUF_FORMAT: + * info.format = self.view.format # <<<<<<<<<<<<<< + * else: + * info.format = NULL */ + __pyx_t_3 = __pyx_v_self->view.format; + __pyx_v_info->format = __pyx_t_3; -static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t *__pyx_t_1; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); + /* "View.MemoryView":523 + * info.suboffsets = NULL + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: + */ + goto __pyx_L6; + } - /* "View.MemoryView":687 + /* "View.MemoryView":526 + * info.format = self.view.format + * else: + * info.format = NULL # <<<<<<<<<<<<<< * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") + * info.buf = self.view.buf */ - __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); - for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { - __pyx_t_1 = __pyx_t_3; - __pyx_v_suboffset = (__pyx_t_1[0]); + /*else*/ { + __pyx_v_info->format = NULL; + } + __pyx_L6:; - /* "View.MemoryView":688 - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * raise ValueError("Indirect dimensions not supported") + /* "View.MemoryView":528 + * info.format = NULL * + * info.buf = self.view.buf # <<<<<<<<<<<<<< + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize */ - __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_4) { + __pyx_t_4 = __pyx_v_self->view.buf; + __pyx_v_info->buf = __pyx_t_4; - /* "View.MemoryView":689 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + /* "View.MemoryView":529 * + * info.buf = self.view.buf + * info.ndim = self.view.ndim # <<<<<<<<<<<<<< + * info.itemsize = self.view.itemsize + * info.len = self.view.len + */ + __pyx_t_5 = __pyx_v_self->view.ndim; + __pyx_v_info->ndim = __pyx_t_5; + + /* "View.MemoryView":530 + * info.buf = self.view.buf + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<< + * info.len = self.view.len + * info.readonly = 0 + */ + __pyx_t_6 = __pyx_v_self->view.itemsize; + __pyx_v_info->itemsize = __pyx_t_6; + + /* "View.MemoryView":531 + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize + * info.len = self.view.len # <<<<<<<<<<<<<< + * info.readonly = 0 + * info.obj = self + */ + __pyx_t_6 = __pyx_v_self->view.len; + __pyx_v_info->len = __pyx_t_6; + + /* "View.MemoryView":532 + * info.itemsize = self.view.itemsize + * info.len = self.view.len + * info.readonly = 0 # <<<<<<<<<<<<<< + * info.obj = self * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(2, 689, __pyx_L1_error) + __pyx_v_info->readonly = 0; - /* "View.MemoryView":688 - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * raise ValueError("Indirect dimensions not supported") + /* "View.MemoryView":533 + * info.len = self.view.len + * info.readonly = 0 + * info.obj = self # <<<<<<<<<<<<<< * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") */ - } - } + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - /* "View.MemoryView":686 - * return have_slices or nslices, tuple(result) + /* "View.MemoryView":507 * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_STRIDES: + * info.shape = self.view.shape */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":696 +/* "View.MemoryView":539 * - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< - * cdef int new_ndim = 0, suboffset_dim = -1, dim - * cdef bint negative_step + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) */ -static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) { - int __pyx_v_new_ndim; - int __pyx_v_suboffset_dim; - int __pyx_v_dim; - __Pyx_memviewslice __pyx_v_src; - __Pyx_memviewslice __pyx_v_dst; - __Pyx_memviewslice *__pyx_v_p_src; - struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0; - __Pyx_memviewslice *__pyx_v_p_dst; - int *__pyx_v_p_suboffset_dim; - Py_ssize_t __pyx_v_start; - Py_ssize_t __pyx_v_stop; - Py_ssize_t __pyx_v_step; - int __pyx_v_have_start; - int __pyx_v_have_stop; - int __pyx_v_have_step; - PyObject *__pyx_v_index = NULL; - struct __pyx_memoryview_obj *__pyx_r = NULL; +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - int __pyx_t_1; + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - struct __pyx_memoryview_obj *__pyx_t_4; - char *__pyx_t_5; - int __pyx_t_6; - Py_ssize_t __pyx_t_7; - PyObject *(*__pyx_t_8)(PyObject *); - PyObject *__pyx_t_9 = NULL; - Py_ssize_t __pyx_t_10; - int __pyx_t_11; - Py_ssize_t __pyx_t_12; - __Pyx_RefNannySetupContext("memview_slice", 0); + __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":697 - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): - * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< - * cdef bint negative_step - * cdef __Pyx_memviewslice src, dst + /* "View.MemoryView":540 + * @property + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<< + * transpose_memslice(&result.from_slice) + * return result */ - __pyx_v_new_ndim = 0; - __pyx_v_suboffset_dim = -1; + __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 540, __pyx_L1_error) + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1); + __pyx_t_1 = 0; - /* "View.MemoryView":704 - * - * - * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< + /* "View.MemoryView":541 + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<< + * return result * - * cdef _memoryviewslice memviewsliceobj */ - memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))); + __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 541, __pyx_L1_error) - /* "View.MemoryView":708 - * cdef _memoryviewslice memviewsliceobj - * - * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":542 + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + * return result # <<<<<<<<<<<<<< * - * if isinstance(memview, _memoryviewslice): + * @property */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(2, 708, __pyx_L1_error) - } - } - #endif + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; - /* "View.MemoryView":710 - * assert memview.view.ndim > 0 + /* "View.MemoryView":539 * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - /* "View.MemoryView":711 + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":545 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj * - * if isinstance(memview, _memoryviewslice): - * memviewsliceobj = memview # <<<<<<<<<<<<<< - * p_src = &memviewsliceobj.from_slice - * else: */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 711, __pyx_L1_error) - __pyx_t_3 = ((PyObject *)__pyx_v_memview); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); - __pyx_t_3 = 0; - /* "View.MemoryView":712 - * if isinstance(memview, _memoryviewslice): - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< - * else: - * slice_copy(memview, &src) - */ - __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice); +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":710 - * assert memview.view.ndim > 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice - */ - goto __pyx_L3; - } + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":714 - * p_src = &memviewsliceobj.from_slice - * else: - * slice_copy(memview, &src) # <<<<<<<<<<<<<< - * p_src = &src - * - */ - /*else*/ { - __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":715 - * else: - * slice_copy(memview, &src) - * p_src = &src # <<<<<<<<<<<<<< - * + /* "View.MemoryView":546 + * @property + * def base(self): + * return self.obj # <<<<<<<<<<<<<< * + * @property */ - __pyx_v_p_src = (&__pyx_v_src); - } - __pyx_L3:; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->obj); + __pyx_r = __pyx_v_self->obj; + goto __pyx_L0; - /* "View.MemoryView":721 - * + /* "View.MemoryView":545 * - * dst.memview = p_src.memview # <<<<<<<<<<<<<< - * dst.data = p_src.data + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj * */ - __pyx_t_4 = __pyx_v_p_src->memview; - __pyx_v_dst.memview = __pyx_t_4; - /* "View.MemoryView":722 - * - * dst.memview = p_src.memview - * dst.data = p_src.data # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_5 = __pyx_v_p_src->data; - __pyx_v_dst.data = __pyx_t_5; + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":727 - * +/* "View.MemoryView":549 * - * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< - * cdef int *p_suboffset_dim = &suboffset_dim - * cdef Py_ssize_t start, stop, step - */ - __pyx_v_p_dst = (&__pyx_v_dst); - - /* "View.MemoryView":728 + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) * - * cdef __Pyx_memviewslice *p_dst = &dst - * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< - * cdef Py_ssize_t start, stop, step - * cdef bint have_start, have_stop, have_step */ - __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); - /* "View.MemoryView":732 - * cdef bint have_start, have_stop, have_step - * - * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< - * if PyIndex_Check(index): - * slice_memviewslice( - */ - __pyx_t_6 = 0; - if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) { - __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - } else { - __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 732, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 732, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_8)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) - #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - #endif - } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) - #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - #endif - } - } else { - __pyx_t_9 = __pyx_t_8(__pyx_t_3); - if (unlikely(!__pyx_t_9)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(2, 732, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_9); - } - __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_v_dim = __pyx_t_6; - __pyx_t_6 = (__pyx_t_6 + 1); +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":733 + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_length; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":550 + * @property + * def shape(self): + * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< * - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): # <<<<<<<<<<<<<< - * slice_memviewslice( - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * @property */ - __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); - if (__pyx_t_2) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { + __pyx_t_2 = __pyx_t_4; + __pyx_v_length = (__pyx_t_2[0]); + __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 550, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; - /* "View.MemoryView":737 - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, - * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< - * 0, 0, 0, # have_{start,stop,step} - * False) + /* "View.MemoryView":549 + * + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * */ - __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 737, __pyx_L1_error) - /* "View.MemoryView":734 - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): - * slice_memviewslice( # <<<<<<<<<<<<<< - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, - */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 734, __pyx_L1_error) + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":733 +/* "View.MemoryView":553 + * + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: * - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): # <<<<<<<<<<<<<< - * slice_memviewslice( - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], */ - goto __pyx_L6; - } - /* "View.MemoryView":740 - * 0, 0, 0, # have_{start,stop,step} - * False) - * elif index is None: # <<<<<<<<<<<<<< - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 - */ - __pyx_t_2 = (__pyx_v_index == Py_None); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":741 - * False) - * elif index is None: - * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 - */ - (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":742 - * elif index is None: - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< - * p_dst.suboffsets[new_ndim] = -1 - * new_ndim += 1 - */ - (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_stride; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":743 - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< - * new_ndim += 1 - * else: + /* "View.MemoryView":554 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") */ - (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; + __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":744 - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 - * new_ndim += 1 # <<<<<<<<<<<<<< - * else: - * start = index.start or 0 + /* "View.MemoryView":556 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(2, 556, __pyx_L1_error) - /* "View.MemoryView":740 - * 0, 0, 0, # have_{start,stop,step} - * False) - * elif index is None: # <<<<<<<<<<<<<< - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 + /* "View.MemoryView":554 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") */ - goto __pyx_L6; - } + } - /* "View.MemoryView":746 - * new_ndim += 1 - * else: - * start = index.start or 0 # <<<<<<<<<<<<<< - * stop = index.stop or 0 - * step = index.step or 0 + /* "View.MemoryView":558 + * raise ValueError("Buffer view does not expose strides") + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property */ - /*else*/ { - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 746, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 746, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 746, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L7_bool_binop_done:; - __pyx_v_start = __pyx_t_10; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_v_stride = (__pyx_t_3[0]); + __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 558, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L0; - /* "View.MemoryView":747 - * else: - * start = index.start or 0 - * stop = index.stop or 0 # <<<<<<<<<<<<<< - * step = index.step or 0 + /* "View.MemoryView":553 * - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 747, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 747, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 747, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L9_bool_binop_done:; - __pyx_v_stop = __pyx_t_10; - - /* "View.MemoryView":748 - * start = index.start or 0 - * stop = index.stop or 0 - * step = index.step or 0 # <<<<<<<<<<<<<< + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: * - * have_start = index.start is not None */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 748, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 748, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 748, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L11_bool_binop_done:; - __pyx_v_step = __pyx_t_10; - /* "View.MemoryView":750 - * step = index.step or 0 - * - * have_start = index.start is not None # <<<<<<<<<<<<<< - * have_stop = index.stop is not None - * have_step = index.step is not None - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 750, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_start = __pyx_t_1; + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":751 - * - * have_start = index.start is not None - * have_stop = index.stop is not None # <<<<<<<<<<<<<< - * have_step = index.step is not None +/* "View.MemoryView":561 * + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 751, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_stop = __pyx_t_1; - /* "View.MemoryView":752 - * have_start = index.start is not None - * have_stop = index.stop is not None - * have_step = index.step is not None # <<<<<<<<<<<<<< +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + Py_ssize_t *__pyx_t_6; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":562 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim * - * slice_memviewslice( */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 752, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_step = __pyx_t_1; + __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":754 - * have_step = index.step is not None + /* "View.MemoryView":563 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< * - * slice_memviewslice( # <<<<<<<<<<<<<< - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 754, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__17, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; - /* "View.MemoryView":760 - * have_start, have_stop, have_step, - * True) - * new_ndim += 1 # <<<<<<<<<<<<<< + /* "View.MemoryView":562 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim * - * if isinstance(memview, _memoryviewslice): */ - __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); - } - __pyx_L6:; + } - /* "View.MemoryView":732 - * cdef bint have_start, have_stop, have_step + /* "View.MemoryView":565 + * return (-1,) * self.view.ndim * - * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< - * if PyIndex_Check(index): - * slice_memviewslice( + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); + for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { + __pyx_t_4 = __pyx_t_6; + __pyx_v_suboffset = (__pyx_t_4[0]); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 565, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } + __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 565, __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; + goto __pyx_L0; - /* "View.MemoryView":762 - * new_ndim += 1 + /* "View.MemoryView":561 * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - /* "View.MemoryView":763 - * - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":764 - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< - * memviewsliceobj.to_dtype_func, - * memview.dtype_is_object) +/* "View.MemoryView":568 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim + * */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 764, __pyx_L1_error) } - /* "View.MemoryView":765 - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< - * memview.dtype_is_object) - * else: - */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 765, __pyx_L1_error) } +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":763 - * - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, - */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 763, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 763, __pyx_L1_error) - __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":762 - * new_ndim += 1 +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":569 + * @property + * def ndim(self): + * return self.view.ndim # <<<<<<<<<<<<<< * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, + * @property */ - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 569, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":768 - * memview.dtype_is_object) - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< - * memview.dtype_is_object) + /* "View.MemoryView":568 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim * */ - /*else*/ { - __Pyx_XDECREF(((PyObject *)__pyx_r)); - /* "View.MemoryView":769 - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, - * memview.dtype_is_object) # <<<<<<<<<<<<<< + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":572 * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize * */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 768, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - /* "View.MemoryView":768 - * memview.dtype_is_object) - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< - * memview.dtype_is_object) +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":573 + * @property + * def itemsize(self): + * return self.view.itemsize # <<<<<<<<<<<<<< * + * @property */ - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 768, __pyx_L1_error) - __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 573, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":696 + /* "View.MemoryView":572 + * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize * - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< - * cdef int new_ndim = 0, suboffset_dim = -1, dim - * cdef bint negative_step */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj); - __Pyx_XDECREF(__pyx_v_index); - __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":793 +/* "View.MemoryView":576 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize * - * @cname('__pyx_memoryview_slice_memviewslice') - * cdef int slice_memviewslice( # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, */ -static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) { - Py_ssize_t __pyx_v_new_shape; - int __pyx_v_negative_step; - int __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":813 - * cdef bint negative_step - * - * if not is_slice: # <<<<<<<<<<<<<< - * - * if start < 0: - */ - __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); - if (__pyx_t_1) { + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":815 - * if not is_slice: +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":577 + * @property + * def nbytes(self): + * return self.size * self.view.itemsize # <<<<<<<<<<<<<< * - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if not 0 <= start < shape: + * @property */ - __pyx_t_1 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; - /* "View.MemoryView":816 + /* "View.MemoryView":576 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize * - * if start < 0: - * start += shape # <<<<<<<<<<<<<< - * if not 0 <= start < shape: - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) */ - __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - /* "View.MemoryView":815 - * if not is_slice: + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":580 * - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if not 0 <= start < shape: + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 */ - } - /* "View.MemoryView":817 - * if start < 0: - * start += shape - * if not 0 <= start < shape: # <<<<<<<<<<<<<< - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) - * else: - */ - __pyx_t_1 = (0 <= __pyx_v_start); - if (__pyx_t_1) { - __pyx_t_1 = (__pyx_v_start < __pyx_v_shape); - } - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":818 - * start += shape - * if not 0 <= start < shape: - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< - * else: + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":581 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 * */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 818, __pyx_L1_error) + __pyx_t_1 = (__pyx_v_self->_size == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":817 - * if start < 0: - * start += shape - * if not 0 <= start < shape: # <<<<<<<<<<<<<< - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) - * else: + /* "View.MemoryView":582 + * def size(self): + * if self._size is None: + * result = 1 # <<<<<<<<<<<<<< + * + * for length in self.view.shape[:self.view.ndim]: */ - } + __Pyx_INCREF(__pyx_int_1); + __pyx_v_result = __pyx_int_1; - /* "View.MemoryView":813 - * cdef bint negative_step + /* "View.MemoryView":584 + * result = 1 * - * if not is_slice: # <<<<<<<<<<<<<< + * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< + * result *= length * - * if start < 0: */ - goto __pyx_L3; - } + __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 584, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); + __pyx_t_6 = 0; - /* "View.MemoryView":821 - * else: + /* "View.MemoryView":585 * - * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< + * for length in self.view.shape[:self.view.ndim]: + * result *= length # <<<<<<<<<<<<<< * - * if have_step and step == 0: + * self._size = result */ - /*else*/ { - __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); - if (__pyx_t_1) { - } else { - __pyx_t_2 = __pyx_t_1; - goto __pyx_L6_bool_binop_done; + __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 585, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); + __pyx_t_6 = 0; } - __pyx_t_1 = ((__pyx_v_step < 0) != 0); - __pyx_t_2 = __pyx_t_1; - __pyx_L6_bool_binop_done:; - __pyx_v_negative_step = __pyx_t_2; - /* "View.MemoryView":823 - * negative_step = have_step != 0 and step < 0 + /* "View.MemoryView":587 + * result *= length * - * if have_step and step == 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * self._size = result # <<<<<<<<<<<<<< * + * return self._size */ - __pyx_t_1 = (__pyx_v_have_step != 0); - if (__pyx_t_1) { - } else { - __pyx_t_2 = __pyx_t_1; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_1 = ((__pyx_v_step == 0) != 0); - __pyx_t_2 = __pyx_t_1; - __pyx_L9_bool_binop_done:; - if (__pyx_t_2) { + __Pyx_INCREF(__pyx_v_result); + __Pyx_GIVEREF(__pyx_v_result); + __Pyx_GOTREF(__pyx_v_self->_size); + __Pyx_DECREF(__pyx_v_self->_size); + __pyx_v_self->_size = __pyx_v_result; - /* "View.MemoryView":824 - * - * if have_step and step == 0: - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":581 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 * */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 824, __pyx_L1_error) + } - /* "View.MemoryView":823 - * negative_step = have_step != 0 and step < 0 + /* "View.MemoryView":589 + * self._size = result * - * if have_step and step == 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * return self._size # <<<<<<<<<<<<<< * + * def __len__(self): */ - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_size); + __pyx_r = __pyx_v_self->_size; + goto __pyx_L0; - /* "View.MemoryView":827 - * + /* "View.MemoryView":580 * - * if have_start: # <<<<<<<<<<<<<< - * if start < 0: - * start += shape + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 */ - __pyx_t_2 = (__pyx_v_have_start != 0); - if (__pyx_t_2) { - /* "View.MemoryView":828 + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":591 + * return self._size * - * if have_start: - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if start < 0: + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] */ - __pyx_t_2 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_2) { - /* "View.MemoryView":829 - * if have_start: - * if start < 0: - * start += shape # <<<<<<<<<<<<<< - * if start < 0: - * start = 0 - */ - __pyx_v_start = (__pyx_v_start + __pyx_v_shape); +/* Python wrapper */ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":830 - * if start < 0: - * start += shape - * if start < 0: # <<<<<<<<<<<<<< - * start = 0 - * elif start >= shape: - */ - __pyx_t_2 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_2) { + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":831 - * start += shape - * if start < 0: - * start = 0 # <<<<<<<<<<<<<< - * elif start >= shape: - * if negative_step: - */ - __pyx_v_start = 0; +static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__len__", 0); - /* "View.MemoryView":830 - * if start < 0: - * start += shape - * if start < 0: # <<<<<<<<<<<<<< - * start = 0 - * elif start >= shape: + /* "View.MemoryView":592 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * */ - } + __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":828 + /* "View.MemoryView":593 + * def __len__(self): + * if self.view.ndim >= 1: + * return self.view.shape[0] # <<<<<<<<<<<<<< * - * if have_start: - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if start < 0: + * return 0 */ - goto __pyx_L12; - } - - /* "View.MemoryView":832 - * if start < 0: - * start = 0 - * elif start >= shape: # <<<<<<<<<<<<<< - * if negative_step: - * start = shape - 1 - */ - __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":833 - * start = 0 - * elif start >= shape: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { + __pyx_r = (__pyx_v_self->view.shape[0]); + goto __pyx_L0; - /* "View.MemoryView":834 - * elif start >= shape: - * if negative_step: - * start = shape - 1 # <<<<<<<<<<<<<< - * else: - * start = shape + /* "View.MemoryView":592 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * */ - __pyx_v_start = (__pyx_v_shape - 1); + } - /* "View.MemoryView":833 - * start = 0 - * elif start >= shape: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: + /* "View.MemoryView":595 + * return self.view.shape[0] + * + * return 0 # <<<<<<<<<<<<<< + * + * def __repr__(self): */ - goto __pyx_L14; - } + __pyx_r = 0; + goto __pyx_L0; - /* "View.MemoryView":836 - * start = shape - 1 - * else: - * start = shape # <<<<<<<<<<<<<< - * else: - * if negative_step: + /* "View.MemoryView":591 + * return self._size + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] */ - /*else*/ { - __pyx_v_start = __pyx_v_shape; - } - __pyx_L14:; - /* "View.MemoryView":832 - * if start < 0: - * start = 0 - * elif start >= shape: # <<<<<<<<<<<<<< - * if negative_step: - * start = shape - 1 - */ - } - __pyx_L12:; + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":827 - * +/* "View.MemoryView":597 + * return 0 * - * if have_start: # <<<<<<<<<<<<<< - * if start < 0: - * start += shape + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) */ - goto __pyx_L11; - } - /* "View.MemoryView":838 - * start = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - /*else*/ { - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { +/* Python wrapper */ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":839 - * else: - * if negative_step: - * start = shape - 1 # <<<<<<<<<<<<<< - * else: - * start = 0 - */ - __pyx_v_start = (__pyx_v_shape - 1); + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":838 - * start = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - goto __pyx_L15; - } +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); - /* "View.MemoryView":841 - * start = shape - 1 - * else: - * start = 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":598 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) * - * if have_stop: */ - /*else*/ { - __pyx_v_start = 0; - } - __pyx_L15:; - } - __pyx_L11:; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "View.MemoryView":843 - * start = 0 + /* "View.MemoryView":599 + * def __repr__(self): + * return "" % (self.base.__class__.__name__, + * id(self)) # <<<<<<<<<<<<<< * - * if have_stop: # <<<<<<<<<<<<<< - * if stop < 0: - * stop += shape + * def __str__(self): */ - __pyx_t_2 = (__pyx_v_have_stop != 0); - if (__pyx_t_2) { + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 599, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 599, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "View.MemoryView":844 + /* "View.MemoryView":598 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) * - * if have_stop: - * if stop < 0: # <<<<<<<<<<<<<< - * stop += shape - * if stop < 0: */ - __pyx_t_2 = ((__pyx_v_stop < 0) != 0); - if (__pyx_t_2) { + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; - /* "View.MemoryView":845 - * if have_stop: - * if stop < 0: - * stop += shape # <<<<<<<<<<<<<< - * if stop < 0: - * stop = 0 + /* "View.MemoryView":597 + * return 0 + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) */ - __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); - /* "View.MemoryView":846 - * if stop < 0: - * stop += shape - * if stop < 0: # <<<<<<<<<<<<<< - * stop = 0 - * elif stop > shape: - */ - __pyx_t_2 = ((__pyx_v_stop < 0) != 0); - if (__pyx_t_2) { + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":847 - * stop += shape - * if stop < 0: - * stop = 0 # <<<<<<<<<<<<<< - * elif stop > shape: - * stop = shape +/* "View.MemoryView":601 + * id(self)) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) + * */ - __pyx_v_stop = 0; - - /* "View.MemoryView":846 - * if stop < 0: - * stop += shape - * if stop < 0: # <<<<<<<<<<<<<< - * stop = 0 - * elif stop > shape: - */ - } - - /* "View.MemoryView":844 - * - * if have_stop: - * if stop < 0: # <<<<<<<<<<<<<< - * stop += shape - * if stop < 0: - */ - goto __pyx_L17; - } - - /* "View.MemoryView":848 - * if stop < 0: - * stop = 0 - * elif stop > shape: # <<<<<<<<<<<<<< - * stop = shape - * else: - */ - __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":849 - * stop = 0 - * elif stop > shape: - * stop = shape # <<<<<<<<<<<<<< - * else: - * if negative_step: - */ - __pyx_v_stop = __pyx_v_shape; - - /* "View.MemoryView":848 - * if stop < 0: - * stop = 0 - * elif stop > shape: # <<<<<<<<<<<<<< - * stop = shape - * else: - */ - } - __pyx_L17:; - - /* "View.MemoryView":843 - * start = 0 - * - * if have_stop: # <<<<<<<<<<<<<< - * if stop < 0: - * stop += shape - */ - goto __pyx_L16; - } - /* "View.MemoryView":851 - * stop = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * stop = -1 - * else: - */ - /*else*/ { - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { +/* Python wrapper */ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":852 - * else: - * if negative_step: - * stop = -1 # <<<<<<<<<<<<<< - * else: - * stop = shape - */ - __pyx_v_stop = -1L; + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":851 - * stop = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * stop = -1 - * else: - */ - goto __pyx_L19; - } +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__str__", 0); - /* "View.MemoryView":854 - * stop = -1 - * else: - * stop = shape # <<<<<<<<<<<<<< + /* "View.MemoryView":602 * - * if not have_step: - */ - /*else*/ { - __pyx_v_stop = __pyx_v_shape; - } - __pyx_L19:; - } - __pyx_L16:; - - /* "View.MemoryView":856 - * stop = shape + * def __str__(self): + * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<< * - * if not have_step: # <<<<<<<<<<<<<< - * step = 1 * */ - __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); - if (__pyx_t_2) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 602, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":857 - * - * if not have_step: - * step = 1 # <<<<<<<<<<<<<< + /* "View.MemoryView":601 + * id(self)) * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) * */ - __pyx_v_step = 1; - /* "View.MemoryView":856 - * stop = shape - * - * if not have_step: # <<<<<<<<<<<<<< - * step = 1 - * - */ - } + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":861 +/* "View.MemoryView":605 * - * with cython.cdivision(True): - * new_shape = (stop - start) // step # <<<<<<<<<<<<<< * - * if (stop - start) - step * new_shape: + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp */ - __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); - /* "View.MemoryView":863 - * new_shape = (stop - start) // step - * - * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< - * new_shape += 1 - * - */ - __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); - if (__pyx_t_2) { +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":864 - * - * if (stop - start) - step * new_shape: - * new_shape += 1 # <<<<<<<<<<<<<< - * - * if new_shape < 0: - */ - __pyx_v_new_shape = (__pyx_v_new_shape + 1); + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":863 - * new_shape = (stop - start) // step - * - * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< - * new_shape += 1 +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("is_c_contig", 0); + + /* "View.MemoryView":608 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'C', self.view.ndim) * */ - } + __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); - /* "View.MemoryView":866 - * new_shape += 1 - * - * if new_shape < 0: # <<<<<<<<<<<<<< - * new_shape = 0 + /* "View.MemoryView":609 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<< * + * def is_f_contig(self): */ - __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); - if (__pyx_t_2) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 609, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":867 - * - * if new_shape < 0: - * new_shape = 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":605 * * + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp */ - __pyx_v_new_shape = 0; - /* "View.MemoryView":866 - * new_shape += 1 - * - * if new_shape < 0: # <<<<<<<<<<<<<< - * new_shape = 0 + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":611 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp */ - } - /* "View.MemoryView":870 - * +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("is_f_contig", 0); + + /* "View.MemoryView":614 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'F', self.view.ndim) * - * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< - * dst.shape[new_ndim] = new_shape - * dst.suboffsets[new_ndim] = suboffset */ - (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); + __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); - /* "View.MemoryView":871 - * - * dst.strides[new_ndim] = stride * step - * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< - * dst.suboffsets[new_ndim] = suboffset + /* "View.MemoryView":615 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<< * + * def copy(self): */ - (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 615, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "View.MemoryView":872 - * dst.strides[new_ndim] = stride * step - * dst.shape[new_ndim] = new_shape - * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< - * + /* "View.MemoryView":611 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp */ - (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset; - } - __pyx_L3:; - /* "View.MemoryView":875 - * + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":617 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) * - * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< - * dst.data += start * stride - * else: + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS */ - __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); - if (__pyx_t_2) { - /* "View.MemoryView":876 +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_mslice; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("copy", 0); + + /* "View.MemoryView":619 + * def copy(self): + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<< * - * if suboffset_dim[0] < 0: - * dst.data += start * stride # <<<<<<<<<<<<<< - * else: - * dst.suboffsets[suboffset_dim[0]] += start * stride + * slice_copy(self, &mslice) */ - __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride)); + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS)); - /* "View.MemoryView":875 - * + /* "View.MemoryView":621 + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS * - * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< - * dst.data += start * stride - * else: + * slice_copy(self, &mslice) # <<<<<<<<<<<<<< + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, + * self.view.itemsize, */ - goto __pyx_L23; - } + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice)); - /* "View.MemoryView":878 - * dst.data += start * stride - * else: - * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< + /* "View.MemoryView":622 * - * if suboffset >= 0: + * slice_copy(self, &mslice) + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_C_CONTIGUOUS, */ - /*else*/ { - __pyx_t_3 = (__pyx_v_suboffset_dim[0]); - (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride)); - } - __pyx_L23:; + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 622, __pyx_L1_error) + __pyx_v_mslice = __pyx_t_1; - /* "View.MemoryView":880 - * dst.suboffsets[suboffset_dim[0]] += start * stride + /* "View.MemoryView":627 + * self.dtype_is_object) * - * if suboffset >= 0: # <<<<<<<<<<<<<< - * if not is_slice: - * if new_ndim == 0: + * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<< + * + * def copy_fortran(self): */ - __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_2) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 627, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; - /* "View.MemoryView":881 + /* "View.MemoryView":617 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) * - * if suboffset >= 0: - * if not is_slice: # <<<<<<<<<<<<<< - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS */ - __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); - if (__pyx_t_2) { - /* "View.MemoryView":882 - * if suboffset >= 0: - * if not is_slice: - * if new_ndim == 0: # <<<<<<<<<<<<<< - * dst.data = ( dst.data)[0] + suboffset - * else: - */ - __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); - if (__pyx_t_2) { + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":883 - * if not is_slice: - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " +/* "View.MemoryView":629 + * return memoryview_copy_from_slice(self, &mslice) + * + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS */ - __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset); - /* "View.MemoryView":882 - * if suboffset >= 0: - * if not is_slice: - * if new_ndim == 0: # <<<<<<<<<<<<<< - * dst.data = ( dst.data)[0] + suboffset - * else: - */ - goto __pyx_L26; - } +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); - /* "View.MemoryView":885 - * dst.data = ( dst.data)[0] + suboffset - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< - * "must be indexed and not sliced", dim) - * else: - */ - /*else*/ { + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":886 - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " - * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<< - * else: - * suboffset_dim[0] = new_ndim - */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 885, __pyx_L1_error) - } - __pyx_L26:; +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("copy_fortran", 0); - /* "View.MemoryView":881 + /* "View.MemoryView":631 + * def copy_fortran(self): + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<< * - * if suboffset >= 0: - * if not is_slice: # <<<<<<<<<<<<<< - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset + * slice_copy(self, &src) */ - goto __pyx_L25; - } + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS)); - /* "View.MemoryView":888 - * "must be indexed and not sliced", dim) - * else: - * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< + /* "View.MemoryView":633 + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS * - * return 0 + * slice_copy(self, &src) # <<<<<<<<<<<<<< + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, + * self.view.itemsize, */ - /*else*/ { - (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim; - } - __pyx_L25:; + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src)); - /* "View.MemoryView":880 - * dst.suboffsets[suboffset_dim[0]] += start * stride + /* "View.MemoryView":634 * - * if suboffset >= 0: # <<<<<<<<<<<<<< - * if not is_slice: - * if new_ndim == 0: + * slice_copy(self, &src) + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_F_CONTIGUOUS, */ - } + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 634, __pyx_L1_error) + __pyx_v_dst = __pyx_t_1; - /* "View.MemoryView":890 - * suboffset_dim[0] = new_ndim + /* "View.MemoryView":639 + * self.dtype_is_object) * - * return 0 # <<<<<<<<<<<<<< + * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<< * * */ - __pyx_r = 0; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 639, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; - /* "View.MemoryView":793 + /* "View.MemoryView":629 + * return memoryview_copy_from_slice(self, &mslice) * - * @cname('__pyx_memoryview_slice_memviewslice') - * cdef int slice_memviewslice( # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS */ /* function exit code */ __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = -1; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":896 +/* "View.MemoryView":643 * - * @cname('__pyx_pybuffer_index') - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo */ -static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) { - Py_ssize_t __pyx_v_shape; - Py_ssize_t __pyx_v_stride; - Py_ssize_t __pyx_v_suboffset; - Py_ssize_t __pyx_v_itemsize; - char *__pyx_v_resultp; - char *__pyx_r; +static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) { + struct __pyx_memoryview_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - __Pyx_RefNannySetupContext("pybuffer_index", 0); + __Pyx_RefNannySetupContext("memoryview_cwrapper", 0); - /* "View.MemoryView":898 - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< - * cdef Py_ssize_t itemsize = view.itemsize - * cdef char *resultp + /* "View.MemoryView":644 + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<< + * result.typeinfo = typeinfo + * return result */ - __pyx_v_suboffset = -1L; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_o); + __Pyx_GIVEREF(__pyx_v_o); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 644, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2); + __pyx_t_2 = 0; - /* "View.MemoryView":899 - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 - * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< - * cdef char *resultp + /* "View.MemoryView":645 + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo # <<<<<<<<<<<<<< + * return result * */ - __pyx_t_1 = __pyx_v_view->itemsize; - __pyx_v_itemsize = __pyx_t_1; + __pyx_v_result->typeinfo = __pyx_v_typeinfo; - /* "View.MemoryView":902 - * cdef char *resultp + /* "View.MemoryView":646 + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + * return result # <<<<<<<<<<<<<< * - * if view.ndim == 0: # <<<<<<<<<<<<<< - * shape = view.len / itemsize - * stride = itemsize + * @cname('__pyx_memoryview_check') */ - __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); - if (__pyx_t_2) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; - /* "View.MemoryView":903 + /* "View.MemoryView":643 * - * if view.ndim == 0: - * shape = view.len / itemsize # <<<<<<<<<<<<<< - * stride = itemsize - * else: + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo */ - if (unlikely(__pyx_v_itemsize == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - __PYX_ERR(2, 903, __pyx_L1_error) - } - else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { - PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); - __PYX_ERR(2, 903, __pyx_L1_error) - } - __pyx_v_shape = (__pyx_v_view->len / __pyx_v_itemsize); - /* "View.MemoryView":904 - * if view.ndim == 0: - * shape = view.len / itemsize - * stride = itemsize # <<<<<<<<<<<<<< - * else: - * shape = view.shape[dim] - */ - __pyx_v_stride = __pyx_v_itemsize; + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":902 - * cdef char *resultp +/* "View.MemoryView":649 + * + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) * - * if view.ndim == 0: # <<<<<<<<<<<<<< - * shape = view.len / itemsize - * stride = itemsize - */ - goto __pyx_L3; - } - - /* "View.MemoryView":906 - * stride = itemsize - * else: - * shape = view.shape[dim] # <<<<<<<<<<<<<< - * stride = view.strides[dim] - * if view.suboffsets != NULL: */ - /*else*/ { - __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); - /* "View.MemoryView":907 - * else: - * shape = view.shape[dim] - * stride = view.strides[dim] # <<<<<<<<<<<<<< - * if view.suboffsets != NULL: - * suboffset = view.suboffsets[dim] - */ - __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); - - /* "View.MemoryView":908 - * shape = view.shape[dim] - * stride = view.strides[dim] - * if view.suboffsets != NULL: # <<<<<<<<<<<<<< - * suboffset = view.suboffsets[dim] - * - */ - __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":909 - * stride = view.strides[dim] - * if view.suboffsets != NULL: - * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< - * - * if index < 0: - */ - __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]); - - /* "View.MemoryView":908 - * shape = view.shape[dim] - * stride = view.strides[dim] - * if view.suboffsets != NULL: # <<<<<<<<<<<<<< - * suboffset = view.suboffsets[dim] - * - */ - } - } - __pyx_L3:; +static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("memoryview_check", 0); - /* "View.MemoryView":911 - * suboffset = view.suboffsets[dim] + /* "View.MemoryView":650 + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): + * return isinstance(o, memoryview) # <<<<<<<<<<<<<< * - * if index < 0: # <<<<<<<<<<<<<< - * index += view.shape[dim] - * if index < 0: + * cdef tuple _unellipsify(object index, int ndim): */ - __pyx_t_2 = ((__pyx_v_index < 0) != 0); - if (__pyx_t_2) { + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); + __pyx_r = __pyx_t_1; + goto __pyx_L0; - /* "View.MemoryView":912 + /* "View.MemoryView":649 * - * if index < 0: - * index += view.shape[dim] # <<<<<<<<<<<<<< - * if index < 0: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - */ - __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); - - /* "View.MemoryView":913 - * if index < 0: - * index += view.shape[dim] - * if index < 0: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) * */ - __pyx_t_2 = ((__pyx_v_index < 0) != 0); - if (__pyx_t_2) { - /* "View.MemoryView":914 - * index += view.shape[dim] - * if index < 0: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< - * - * if index >= shape: - */ - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(2, 914, __pyx_L1_error) + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":913 - * if index < 0: - * index += view.shape[dim] - * if index < 0: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) +/* "View.MemoryView":652 + * return isinstance(o, memoryview) * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with */ - } - /* "View.MemoryView":911 - * suboffset = view.suboffsets[dim] - * - * if index < 0: # <<<<<<<<<<<<<< - * index += view.shape[dim] - * if index < 0: - */ - } +static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { + PyObject *__pyx_v_tup = NULL; + PyObject *__pyx_v_result = NULL; + int __pyx_v_have_slices; + int __pyx_v_seen_ellipsis; + CYTHON_UNUSED PyObject *__pyx_v_idx = NULL; + PyObject *__pyx_v_item = NULL; + Py_ssize_t __pyx_v_nslices; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + __Pyx_RefNannySetupContext("_unellipsify", 0); - /* "View.MemoryView":916 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - * if index >= shape: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * + /* "View.MemoryView":657 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: */ - __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); + __pyx_t_1 = PyTuple_Check(__pyx_v_index); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":917 - * - * if index >= shape: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< - * - * resultp = bufp + index * stride + /* "View.MemoryView":658 + * """ + * if not isinstance(index, tuple): + * tup = (index,) # <<<<<<<<<<<<<< + * else: + * tup = index */ - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_v_index); + __Pyx_GIVEREF(__pyx_v_index); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index); + __pyx_v_tup = __pyx_t_3; __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 917, __pyx_L1_error) - /* "View.MemoryView":916 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - * if index >= shape: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * + /* "View.MemoryView":657 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: */ + goto __pyx_L3; } - /* "View.MemoryView":919 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + /* "View.MemoryView":660 + * tup = (index,) + * else: + * tup = index # <<<<<<<<<<<<<< * - * resultp = bufp + index * stride # <<<<<<<<<<<<<< - * if suboffset >= 0: - * resultp = ( resultp)[0] + suboffset + * result = [] */ - __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); + /*else*/ { + __Pyx_INCREF(__pyx_v_index); + __pyx_v_tup = __pyx_v_index; + } + __pyx_L3:; - /* "View.MemoryView":920 - * - * resultp = bufp + index * stride - * if suboffset >= 0: # <<<<<<<<<<<<<< - * resultp = ( resultp)[0] + suboffset + /* "View.MemoryView":662 + * tup = index * + * result = [] # <<<<<<<<<<<<<< + * have_slices = False + * seen_ellipsis = False */ - __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_2) { + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 662, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_result = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; - /* "View.MemoryView":921 - * resultp = bufp + index * stride - * if suboffset >= 0: - * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< + /* "View.MemoryView":663 * - * return resultp + * result = [] + * have_slices = False # <<<<<<<<<<<<<< + * seen_ellipsis = False + * for idx, item in enumerate(tup): */ - __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset); + __pyx_v_have_slices = 0; - /* "View.MemoryView":920 - * - * resultp = bufp + index * stride - * if suboffset >= 0: # <<<<<<<<<<<<<< - * resultp = ( resultp)[0] + suboffset - * - */ - } - - /* "View.MemoryView":923 - * resultp = ( resultp)[0] + suboffset - * - * return resultp # <<<<<<<<<<<<<< - * - * + /* "View.MemoryView":664 + * result = [] + * have_slices = False + * seen_ellipsis = False # <<<<<<<<<<<<<< + * for idx, item in enumerate(tup): + * if item is Ellipsis: */ - __pyx_r = __pyx_v_resultp; - goto __pyx_L0; + __pyx_v_seen_ellipsis = 0; - /* "View.MemoryView":896 - * - * @cname('__pyx_pybuffer_index') - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 + /* "View.MemoryView":665 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_3 = __pyx_int_0; + if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) { + __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 665, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } + } else { + __pyx_t_7 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_7)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 665, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_7); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_INCREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3); + __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); + __pyx_t_3 = __pyx_t_7; + __pyx_t_7 = 0; - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":929 - * - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< - * cdef int ndim = memslice.memview.view.ndim - * + /* "View.MemoryView":666 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) */ + __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { -static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { - int __pyx_v_ndim; - Py_ssize_t *__pyx_v_shape; - Py_ssize_t *__pyx_v_strides; - int __pyx_v_i; - int __pyx_v_j; - int __pyx_r; - int __pyx_t_1; - Py_ssize_t *__pyx_t_2; - long __pyx_t_3; - Py_ssize_t __pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - - /* "View.MemoryView":930 - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: - * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< - * - * cdef Py_ssize_t *shape = memslice.shape + /* "View.MemoryView":667 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True */ - __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; - __pyx_v_ndim = __pyx_t_1; + __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":932 - * cdef int ndim = memslice.memview.view.ndim - * - * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< - * cdef Py_ssize_t *strides = memslice.strides - * + /* "View.MemoryView":668 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: */ - __pyx_t_2 = __pyx_v_memslice->shape; - __pyx_v_shape = __pyx_t_2; + __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) + __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__18); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "View.MemoryView":933 - * - * cdef Py_ssize_t *shape = memslice.shape - * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< - * - * + /* "View.MemoryView":669 + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True # <<<<<<<<<<<<<< + * else: + * result.append(slice(None)) */ - __pyx_t_2 = __pyx_v_memslice->strides; - __pyx_v_strides = __pyx_t_2; + __pyx_v_seen_ellipsis = 1; - /* "View.MemoryView":937 - * - * cdef int i, j - * for i in range(ndim / 2): # <<<<<<<<<<<<<< - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] + /* "View.MemoryView":667 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True */ - __pyx_t_3 = (__pyx_v_ndim / 2); - for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) { - __pyx_v_i = __pyx_t_1; + goto __pyx_L7; + } - /* "View.MemoryView":938 - * cdef int i, j - * for i in range(ndim / 2): - * j = ndim - 1 - i # <<<<<<<<<<<<<< - * strides[i], strides[j] = strides[j], strides[i] - * shape[i], shape[j] = shape[j], shape[i] + /* "View.MemoryView":671 + * seen_ellipsis = True + * else: + * result.append(slice(None)) # <<<<<<<<<<<<<< + * have_slices = True + * else: */ - __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); + /*else*/ { + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__19); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) + } + __pyx_L7:; - /* "View.MemoryView":939 - * for i in range(ndim / 2): - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< - * shape[i], shape[j] = shape[j], shape[i] - * + /* "View.MemoryView":672 + * else: + * result.append(slice(None)) + * have_slices = True # <<<<<<<<<<<<<< + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): */ - __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]); - __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]); - (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4; - (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5; + __pyx_v_have_slices = 1; - /* "View.MemoryView":940 - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] - * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + /* "View.MemoryView":666 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) */ - __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]); - __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]); - (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5; - (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4; + goto __pyx_L6; + } - /* "View.MemoryView":942 - * shape[i], shape[j] = shape[j], shape[i] - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + /* "View.MemoryView":674 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) * */ - __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); - if (!__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); - __pyx_t_6 = __pyx_t_7; - __pyx_L6_bool_binop_done:; - if (__pyx_t_6) { + /*else*/ { + __pyx_t_2 = PySlice_Check(__pyx_v_item); + __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); + __pyx_t_1 = __pyx_t_10; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { - /* "View.MemoryView":943 - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< + /* "View.MemoryView":675 + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): + * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<< * - * return 1 + * have_slices = have_slices or isinstance(item, slice) */ - __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 943, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 675, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_Raise(__pyx_t_7, 0, 0, 0); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __PYX_ERR(2, 675, __pyx_L1_error) - /* "View.MemoryView":942 - * shape[i], shape[j] = shape[j], shape[i] - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + /* "View.MemoryView":674 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) * */ - } - } + } - /* "View.MemoryView":945 - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") - * - * return 1 # <<<<<<<<<<<<<< + /* "View.MemoryView":677 + * raise TypeError("Cannot index with type '%s'" % type(item)) * + * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<< + * result.append(item) * */ - __pyx_r = 1; - goto __pyx_L0; + __pyx_t_10 = (__pyx_v_have_slices != 0); + if (!__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = PySlice_Check(__pyx_v_item); + __pyx_t_2 = (__pyx_t_10 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_have_slices = __pyx_t_1; - /* "View.MemoryView":929 + /* "View.MemoryView":678 * - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< - * cdef int ndim = memslice.memview.view.ndim + * have_slices = have_slices or isinstance(item, slice) + * result.append(item) # <<<<<<<<<<<<<< * + * nslices = ndim - len(result) */ + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 678, __pyx_L1_error) + } + __pyx_L6:; - /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif + /* "View.MemoryView":665 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: + */ } - __pyx_r = 0; - __pyx_L0:; - return __pyx_r; -} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; -/* "View.MemoryView":962 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + /* "View.MemoryView":680 + * result.append(item) * + * nslices = ndim - len(result) # <<<<<<<<<<<<<< + * if nslices: + * result.extend([slice(None)] * nslices) */ + __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(2, 680, __pyx_L1_error) + __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5); -/* Python wrapper */ -static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} + /* "View.MemoryView":681 + * + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) + * + */ + __pyx_t_1 = (__pyx_v_nslices != 0); + if (__pyx_t_1) { -static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__", 0); + /* "View.MemoryView":682 + * nslices = ndim - len(result) + * if nslices: + * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + * + * return have_slices or nslices, tuple(result) + */ + __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__20); + __Pyx_GIVEREF(__pyx_slice__20); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__20); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":963 + /* "View.MemoryView":681 * - * def __dealloc__(self): - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) * - * cdef convert_item_to_object(self, char *itemp): */ - __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); + } - /* "View.MemoryView":962 - * cdef int (*to_dtype_func)(char *, object) except 0 + /* "View.MemoryView":684 + * result.extend([slice(None)] * nslices) * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<< + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + */ + __Pyx_XDECREF(__pyx_r); + if (!__pyx_v_have_slices) { + } else { + __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_L14_bool_binop_done:; + __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 684, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = ((PyObject*)__pyx_t_7); + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "View.MemoryView":652 + * return isinstance(o, memoryview) * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with */ /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_tup); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_XDECREF(__pyx_v_item); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); + return __pyx_r; } -/* "View.MemoryView":965 - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) +/* "View.MemoryView":686 + * return have_slices or nslices, tuple(result) * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: */ -static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) { +static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { + Py_ssize_t __pyx_v_suboffset; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("convert_item_to_object", 0); + Py_ssize_t *__pyx_t_1; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); - /* "View.MemoryView":966 + /* "View.MemoryView":687 * - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: # <<<<<<<<<<<<<< - * return self.to_object_func(itemp) - * else: - */ - __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); - if (__pyx_t_1) { + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") + */ + __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); + for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { + __pyx_t_1 = __pyx_t_3; + __pyx_v_suboffset = (__pyx_t_1[0]); - /* "View.MemoryView":967 - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) # <<<<<<<<<<<<<< - * else: - * return memoryview.convert_item_to_object(self, itemp) + /* "View.MemoryView":688 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") + * */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 967, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_4) { - /* "View.MemoryView":966 + /* "View.MemoryView":689 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * * - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: # <<<<<<<<<<<<<< - * return self.to_object_func(itemp) - * else: */ - } + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(2, 689, __pyx_L1_error) - /* "View.MemoryView":969 - * return self.to_object_func(itemp) - * else: - * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< + /* "View.MemoryView":688 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") * - * cdef assign_item_from_object(self, char *itemp, object value): */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 969, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + } } - /* "View.MemoryView":965 - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + /* "View.MemoryView":686 + * return have_slices or nslices, tuple(result) * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -20002,6150 +18703,7959 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor return __pyx_r; } -/* "View.MemoryView":971 - * return memoryview.convert_item_to_object(self, itemp) +/* "View.MemoryView":696 * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step */ -static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { - PyObject *__pyx_r = NULL; +static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) { + int __pyx_v_new_ndim; + int __pyx_v_suboffset_dim; + int __pyx_v_dim; + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + __Pyx_memviewslice *__pyx_v_p_src; + struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0; + __Pyx_memviewslice *__pyx_v_p_dst; + int *__pyx_v_p_suboffset_dim; + Py_ssize_t __pyx_v_start; + Py_ssize_t __pyx_v_stop; + Py_ssize_t __pyx_v_step; + int __pyx_v_have_start; + int __pyx_v_have_stop; + int __pyx_v_have_step; + PyObject *__pyx_v_index = NULL; + struct __pyx_memoryview_obj *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("assign_item_from_object", 0); + struct __pyx_memoryview_obj *__pyx_t_4; + char *__pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + Py_ssize_t __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + __Pyx_RefNannySetupContext("memview_slice", 0); - /* "View.MemoryView":972 - * - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< - * self.to_dtype_func(itemp, value) - * else: + /* "View.MemoryView":697 + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): + * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< + * cdef bint negative_step + * cdef __Pyx_memviewslice src, dst */ - __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); - if (__pyx_t_1) { + __pyx_v_new_ndim = 0; + __pyx_v_suboffset_dim = -1; - /* "View.MemoryView":973 - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< - * else: - * memoryview.assign_item_from_object(self, itemp, value) + /* "View.MemoryView":704 + * + * + * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< + * + * cdef _memoryviewslice memviewsliceobj */ - __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 973, __pyx_L1_error) + memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))); - /* "View.MemoryView":972 + /* "View.MemoryView":708 + * cdef _memoryviewslice memviewsliceobj * - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< - * self.to_dtype_func(itemp, value) - * else: + * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): */ - goto __pyx_L3; + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(2, 708, __pyx_L1_error) + } } + #endif - /* "View.MemoryView":975 - * self.to_dtype_func(itemp, value) - * else: - * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< + /* "View.MemoryView":710 + * assert memview.view.ndim > 0 * - * @property + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice */ - /*else*/ { - __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 975, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __pyx_L3:; + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":971 - * return memoryview.convert_item_to_object(self, itemp) + /* "View.MemoryView":711 * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview # <<<<<<<<<<<<<< + * p_src = &memviewsliceobj.from_slice + * else: */ + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 711, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":712 + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, &src) + */ + __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice); -/* "View.MemoryView":978 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.from_object + /* "View.MemoryView":710 + * assert memview.view.ndim > 0 * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice */ + goto __pyx_L3; + } -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "View.MemoryView":714 + * p_src = &memviewsliceobj.from_slice + * else: + * slice_copy(memview, &src) # <<<<<<<<<<<<<< + * p_src = &src + * + */ + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); -static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":979 - * @property - * def base(self): - * return self.from_object # <<<<<<<<<<<<<< - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->from_object); - __pyx_r = __pyx_v_self->from_object; - goto __pyx_L0; - - /* "View.MemoryView":978 + /* "View.MemoryView":715 + * else: + * slice_copy(memview, &src) + * p_src = &src # <<<<<<<<<<<<<< * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.from_object * */ + __pyx_v_p_src = (&__pyx_v_src); + } + __pyx_L3:; - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":985 + /* "View.MemoryView":721 * - * @cname('__pyx_memoryview_fromslice') - * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< - * int ndim, - * object (*to_object_func)(char *), - */ - -static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { - struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_v_length = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_TypeInfo *__pyx_t_4; - Py_buffer __pyx_t_5; - Py_ssize_t *__pyx_t_6; - Py_ssize_t *__pyx_t_7; - Py_ssize_t *__pyx_t_8; - Py_ssize_t __pyx_t_9; - __Pyx_RefNannySetupContext("memoryview_fromslice", 0); - - /* "View.MemoryView":993 - * cdef _memoryviewslice result * - * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< - * return None + * dst.memview = p_src.memview # <<<<<<<<<<<<<< + * dst.data = p_src.data * */ - __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); - if (__pyx_t_1) { + __pyx_t_4 = __pyx_v_p_src->memview; + __pyx_v_dst.memview = __pyx_t_4; - /* "View.MemoryView":994 + /* "View.MemoryView":722 * - * if memviewslice.memview == Py_None: - * return None # <<<<<<<<<<<<<< + * dst.memview = p_src.memview + * dst.data = p_src.data # <<<<<<<<<<<<<< * * */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; + __pyx_t_5 = __pyx_v_p_src->data; + __pyx_v_dst.data = __pyx_t_5; - /* "View.MemoryView":993 - * cdef _memoryviewslice result + /* "View.MemoryView":727 * - * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< - * return None * + * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< + * cdef int *p_suboffset_dim = &suboffset_dim + * cdef Py_ssize_t start, stop, step */ - } + __pyx_v_p_dst = (&__pyx_v_dst); - /* "View.MemoryView":999 - * - * - * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< + /* "View.MemoryView":728 * - * result.from_slice = memviewslice + * cdef __Pyx_memviewslice *p_dst = &dst + * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< + * cdef Py_ssize_t start, stop, step + * cdef bint have_start, have_stop, have_step */ - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 999, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); - /* "View.MemoryView":1001 - * result = _memoryviewslice(None, 0, dtype_is_object) - * - * result.from_slice = memviewslice # <<<<<<<<<<<<<< - * __PYX_INC_MEMVIEW(&memviewslice, 1) + /* "View.MemoryView":732 + * cdef bint have_start, have_stop, have_step * + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( */ - __pyx_v_result->from_slice = __pyx_v_memviewslice; + __pyx_t_6 = 0; + if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) { + __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 732, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } else { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } + } else { + __pyx_t_9 = __pyx_t_8(__pyx_t_3); + if (unlikely(!__pyx_t_9)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(2, 732, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_v_dim = __pyx_t_6; + __pyx_t_6 = (__pyx_t_6 + 1); - /* "View.MemoryView":1002 - * - * result.from_slice = memviewslice - * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< + /* "View.MemoryView":733 * - * result.from_object = ( memviewslice.memview).base + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], */ - __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); + __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1004 - * __PYX_INC_MEMVIEW(&memviewslice, 1) - * - * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< - * result.typeinfo = memviewslice.memview.typeinfo - * + /* "View.MemoryView":737 + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< + * 0, 0, 0, # have_{start,stop,step} + * False) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1004, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_result->from_object); - __Pyx_DECREF(__pyx_v_result->from_object); - __pyx_v_result->from_object = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 737, __pyx_L1_error) - /* "View.MemoryView":1005 - * - * result.from_object = ( memviewslice.memview).base - * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< - * - * result.view = memviewslice.memview.view + /* "View.MemoryView":734 + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, */ - __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; - __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 734, __pyx_L1_error) - /* "View.MemoryView":1007 - * result.typeinfo = memviewslice.memview.typeinfo + /* "View.MemoryView":733 * - * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< - * result.view.buf = memviewslice.data - * result.view.ndim = ndim + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], */ - __pyx_t_5 = __pyx_v_memviewslice.memview->view; - __pyx_v_result->__pyx_base.view = __pyx_t_5; + goto __pyx_L6; + } - /* "View.MemoryView":1008 - * - * result.view = memviewslice.memview.view - * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None + /* "View.MemoryView":740 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 */ - __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); + __pyx_t_2 = (__pyx_v_index == Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1009 - * result.view = memviewslice.memview.view - * result.view.buf = memviewslice.data - * result.view.ndim = ndim # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &result.view).obj = Py_None - * Py_INCREF(Py_None) + /* "View.MemoryView":741 + * False) + * elif index is None: + * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 */ - __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; + (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; - /* "View.MemoryView":1010 - * result.view.buf = memviewslice.data - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) - * + /* "View.MemoryView":742 + * elif index is None: + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 */ - ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; + (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; - /* "View.MemoryView":1011 - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< - * - * result.flags = PyBUF_RECORDS + /* "View.MemoryView":743 + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< + * new_ndim += 1 + * else: */ - Py_INCREF(Py_None); + (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; - /* "View.MemoryView":1013 - * Py_INCREF(Py_None) - * - * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< - * - * result.view.shape = result.from_slice.shape + /* "View.MemoryView":744 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 # <<<<<<<<<<<<<< + * else: + * start = index.start or 0 */ - __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); - /* "View.MemoryView":1015 - * result.flags = PyBUF_RECORDS - * - * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< - * result.view.strides = result.from_slice.strides - * + /* "View.MemoryView":740 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 */ - __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); + goto __pyx_L6; + } - /* "View.MemoryView":1016 - * - * result.view.shape = result.from_slice.shape - * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< - * - * + /* "View.MemoryView":746 + * new_ndim += 1 + * else: + * start = index.start or 0 # <<<<<<<<<<<<<< + * stop = index.stop or 0 + * step = index.step or 0 */ - __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); + /*else*/ { + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 746, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 746, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 746, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L7_bool_binop_done:; + __pyx_v_start = __pyx_t_10; - /* "View.MemoryView":1019 + /* "View.MemoryView":747 + * else: + * start = index.start or 0 + * stop = index.stop or 0 # <<<<<<<<<<<<<< + * step = index.step or 0 * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 747, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 747, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 747, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L9_bool_binop_done:; + __pyx_v_stop = __pyx_t_10; + + /* "View.MemoryView":748 + * start = index.start or 0 + * stop = index.stop or 0 + * step = index.step or 0 # <<<<<<<<<<<<<< * - * result.view.suboffsets = NULL # <<<<<<<<<<<<<< - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: + * have_start = index.start is not None */ - __pyx_v_result->__pyx_base.view.suboffsets = NULL; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 748, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 748, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 748, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L11_bool_binop_done:; + __pyx_v_step = __pyx_t_10; - /* "View.MemoryView":1020 + /* "View.MemoryView":750 + * step = index.step or 0 * - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets + * have_start = index.start is not None # <<<<<<<<<<<<<< + * have_stop = index.stop is not None + * have_step = index.step is not None */ - __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_v_suboffset = (__pyx_t_6[0]); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 750, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_start = __pyx_t_1; - /* "View.MemoryView":1021 - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * result.view.suboffsets = result.from_slice.suboffsets - * break + /* "View.MemoryView":751 + * + * have_start = index.start is not None + * have_stop = index.stop is not None # <<<<<<<<<<<<<< + * have_step = index.step is not None + * */ - __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_1) { + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 751, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_stop = __pyx_t_1; - /* "View.MemoryView":1022 - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< - * break + /* "View.MemoryView":752 + * have_start = index.start is not None + * have_stop = index.stop is not None + * have_step = index.step is not None # <<<<<<<<<<<<<< * + * slice_memviewslice( */ - __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 752, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_step = __pyx_t_1; - /* "View.MemoryView":1023 - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets - * break # <<<<<<<<<<<<<< + /* "View.MemoryView":754 + * have_step = index.step is not None * - * result.view.len = result.view.itemsize + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, */ - goto __pyx_L5_break; + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(2, 754, __pyx_L1_error) - /* "View.MemoryView":1021 - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * result.view.suboffsets = result.from_slice.suboffsets - * break + /* "View.MemoryView":760 + * have_start, have_stop, have_step, + * True) + * new_ndim += 1 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): */ + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); } - } - __pyx_L5_break:; + __pyx_L6:; - /* "View.MemoryView":1025 - * break + /* "View.MemoryView":732 + * cdef bint have_start, have_stop, have_step * - * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< - * for length in result.view.shape[:ndim]: - * result.view.len *= length + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( */ - __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":1026 + /* "View.MemoryView":762 + * new_ndim += 1 * - * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< - * result.view.len *= length + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":763 * + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, */ - __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1026, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); - __pyx_t_2 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_r)); - /* "View.MemoryView":1027 - * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: - * result.view.len *= length # <<<<<<<<<<<<<< + /* "View.MemoryView":764 + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< + * memviewsliceobj.to_dtype_func, + * memview.dtype_is_object) + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 764, __pyx_L1_error) } + + /* "View.MemoryView":765 + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * else: + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 765, __pyx_L1_error) } + + /* "View.MemoryView":763 * - * result.to_object_func = to_object_func + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1027, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1027, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 1027, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; - } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 763, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; - /* "View.MemoryView":1029 - * result.view.len *= length + /* "View.MemoryView":762 + * new_ndim += 1 * - * result.to_object_func = to_object_func # <<<<<<<<<<<<<< - * result.to_dtype_func = to_dtype_func + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + } + + /* "View.MemoryView":768 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) * */ - __pyx_v_result->to_object_func = __pyx_v_to_object_func; + /*else*/ { + __Pyx_XDECREF(((PyObject *)__pyx_r)); - /* "View.MemoryView":1030 + /* "View.MemoryView":769 + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, + * memview.dtype_is_object) # <<<<<<<<<<<<<< * - * result.to_object_func = to_object_func - * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< * - * return result */ - __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 768, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); - /* "View.MemoryView":1032 - * result.to_dtype_func = to_dtype_func - * - * return result # <<<<<<<<<<<<<< + /* "View.MemoryView":768 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) * - * @cname('__pyx_memoryview_get_slice_from_memoryview') */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 768, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + } - /* "View.MemoryView":985 + /* "View.MemoryView":696 * - * @cname('__pyx_memoryview_fromslice') - * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< - * int ndim, - * object (*to_object_func)(char *), + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XDECREF(__pyx_v_length); - __Pyx_XGIVEREF(__pyx_r); + __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":1035 +/* "View.MemoryView":793 * - * @cname('__pyx_memoryview_get_slice_from_memoryview') - * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *mslice): - * cdef _memoryviewslice obj + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, */ -static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) { - struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0; - __Pyx_memviewslice *__pyx_r; - __Pyx_RefNannyDeclarations +static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) { + Py_ssize_t __pyx_v_new_shape; + int __pyx_v_negative_step; + int __pyx_r; int __pyx_t_1; int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("get_slice_from_memview", 0); + int __pyx_t_3; - /* "View.MemoryView":1038 - * __Pyx_memviewslice *mslice): - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * obj = memview - * return &obj.from_slice + /* "View.MemoryView":813 + * cdef bint negative_step + * + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { + __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1039 - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): - * obj = memview # <<<<<<<<<<<<<< - * return &obj.from_slice - * else: + /* "View.MemoryView":815 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 1039, __pyx_L1_error) - __pyx_t_3 = ((PyObject *)__pyx_v_memview); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_1 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1040 - * if isinstance(memview, _memoryviewslice): - * obj = memview - * return &obj.from_slice # <<<<<<<<<<<<<< - * else: - * slice_copy(memview, mslice) + /* "View.MemoryView":816 + * + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) */ - __pyx_r = (&__pyx_v_obj->from_slice); - goto __pyx_L0; + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - /* "View.MemoryView":1038 - * __Pyx_memviewslice *mslice): - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * obj = memview - * return &obj.from_slice + /* "View.MemoryView":815 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: */ - } + } - /* "View.MemoryView":1042 - * return &obj.from_slice + /* "View.MemoryView":817 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) * else: - * slice_copy(memview, mslice) # <<<<<<<<<<<<<< - * return mslice - * */ - /*else*/ { - __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); + __pyx_t_1 = (0 <= __pyx_v_start); + if (__pyx_t_1) { + __pyx_t_1 = (__pyx_v_start < __pyx_v_shape); + } + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1043 + /* "View.MemoryView":818 + * start += shape + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< * else: - * slice_copy(memview, mslice) - * return mslice # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_slice_copy') */ - __pyx_r = __pyx_v_mslice; - goto __pyx_L0; - } + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 818, __pyx_L1_error) - /* "View.MemoryView":1035 + /* "View.MemoryView":817 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + * else: + */ + } + + /* "View.MemoryView":813 + * cdef bint negative_step * - * @cname('__pyx_memoryview_get_slice_from_memoryview') - * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *mslice): - * cdef _memoryviewslice obj + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: */ + goto __pyx_L3; + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_obj); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1046 + /* "View.MemoryView":821 + * else: * - * @cname('__pyx_memoryview_slice_copy') - * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< - * cdef int dim - * cdef (Py_ssize_t*) shape, strides, suboffsets - */ - -static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) { - int __pyx_v_dim; - Py_ssize_t *__pyx_v_shape; - Py_ssize_t *__pyx_v_strides; - Py_ssize_t *__pyx_v_suboffsets; - __Pyx_RefNannyDeclarations - Py_ssize_t *__pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - Py_ssize_t __pyx_t_4; - __Pyx_RefNannySetupContext("slice_copy", 0); - - /* "View.MemoryView":1050 - * cdef (Py_ssize_t*) shape, strides, suboffsets + * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< * - * shape = memview.view.shape # <<<<<<<<<<<<<< - * strides = memview.view.strides - * suboffsets = memview.view.suboffsets + * if have_step and step == 0: */ - __pyx_t_1 = __pyx_v_memview->view.shape; - __pyx_v_shape = __pyx_t_1; + /*else*/ { + __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step < 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L6_bool_binop_done:; + __pyx_v_negative_step = __pyx_t_2; - /* "View.MemoryView":1051 + /* "View.MemoryView":823 + * negative_step = have_step != 0 and step < 0 * - * shape = memview.view.shape - * strides = memview.view.strides # <<<<<<<<<<<<<< - * suboffsets = memview.view.suboffsets + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) * */ - __pyx_t_1 = __pyx_v_memview->view.strides; - __pyx_v_strides = __pyx_t_1; + __pyx_t_1 = (__pyx_v_have_step != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step == 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L9_bool_binop_done:; + if (__pyx_t_2) { - /* "View.MemoryView":1052 - * shape = memview.view.shape - * strides = memview.view.strides - * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< + /* "View.MemoryView":824 * - * dst.memview = <__pyx_memoryview *> memview - */ - __pyx_t_1 = __pyx_v_memview->view.suboffsets; - __pyx_v_suboffsets = __pyx_t_1; - - /* "View.MemoryView":1054 - * suboffsets = memview.view.suboffsets + * if have_step and step == 0: + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< * - * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< - * dst.data = memview.view.buf * */ - __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 824, __pyx_L1_error) - /* "View.MemoryView":1055 + /* "View.MemoryView":823 + * negative_step = have_step != 0 and step < 0 * - * dst.memview = <__pyx_memoryview *> memview - * dst.data = memview.view.buf # <<<<<<<<<<<<<< + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) * - * for dim in range(memview.view.ndim): */ - __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); + } - /* "View.MemoryView":1057 - * dst.data = memview.view.buf + /* "View.MemoryView":827 * - * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape */ - __pyx_t_2 = __pyx_v_memview->view.ndim; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_dim = __pyx_t_3; + __pyx_t_2 = (__pyx_v_have_start != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1058 + /* "View.MemoryView":828 * - * for dim in range(memview.view.ndim): - * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< - * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: */ - (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1059 - * for dim in range(memview.view.ndim): - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 - * + /* "View.MemoryView":829 + * if have_start: + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if start < 0: + * start = 0 */ - (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - /* "View.MemoryView":1060 - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_object') + /* "View.MemoryView":830 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: */ - if ((__pyx_v_suboffsets != 0)) { - __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]); - } else { - __pyx_t_4 = -1L; - } - (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4; - } + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1046 - * - * @cname('__pyx_memoryview_slice_copy') - * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< - * cdef int dim - * cdef (Py_ssize_t*) shape, strides, suboffsets + /* "View.MemoryView":831 + * start += shape + * if start < 0: + * start = 0 # <<<<<<<<<<<<<< + * elif start >= shape: + * if negative_step: */ + __pyx_v_start = 0; - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} + /* "View.MemoryView":830 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: + */ + } -/* "View.MemoryView":1063 + /* "View.MemoryView":828 * - * @cname('__pyx_memoryview_copy_object') - * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: */ + goto __pyx_L12; + } -static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) { - __Pyx_memviewslice __pyx_v_memviewslice; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("memoryview_copy", 0); - - /* "View.MemoryView":1066 - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice - * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< - * return memoryview_copy_from_slice(memview, &memviewslice) - * + /* "View.MemoryView":832 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 */ - __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); + __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1067 - * cdef __Pyx_memviewslice memviewslice - * slice_copy(memview, &memviewslice) - * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_object_from_slice') + /* "View.MemoryView":833 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1067, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1063 - * - * @cname('__pyx_memoryview_copy_object') - * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice + /* "View.MemoryView":834 + * elif start >= shape: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = shape */ + __pyx_v_start = (__pyx_v_shape - 1); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1070 - * - * @cname('__pyx_memoryview_copy_object_from_slice') - * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< - * """ - * Create a new memoryview object from a given memoryview object and slice. + /* "View.MemoryView":833 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: */ + goto __pyx_L14; + } -static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) { - PyObject *(*__pyx_v_to_object_func)(char *); - int (*__pyx_v_to_dtype_func)(char *, PyObject *); - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *(*__pyx_t_3)(char *); - int (*__pyx_t_4)(char *, PyObject *); - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); + /* "View.MemoryView":836 + * start = shape - 1 + * else: + * start = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: + */ + /*else*/ { + __pyx_v_start = __pyx_v_shape; + } + __pyx_L14:; - /* "View.MemoryView":1077 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + /* "View.MemoryView":832 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { + } + __pyx_L12:; - /* "View.MemoryView":1078 + /* "View.MemoryView":827 * - * if isinstance(memview, _memoryviewslice): - * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - * else: + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape */ - __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; - __pyx_v_to_object_func = __pyx_t_3; + goto __pyx_L11; + } - /* "View.MemoryView":1079 - * if isinstance(memview, _memoryviewslice): - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< - * else: - * to_object_func = NULL + /* "View.MemoryView":838 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: */ - __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func; - __pyx_v_to_dtype_func = __pyx_t_4; + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1077 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + /* "View.MemoryView":839 + * else: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = 0 */ - goto __pyx_L3; - } + __pyx_v_start = (__pyx_v_shape - 1); - /* "View.MemoryView":1081 - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - * else: - * to_object_func = NULL # <<<<<<<<<<<<<< - * to_dtype_func = NULL - * + /* "View.MemoryView":838 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: */ - /*else*/ { - __pyx_v_to_object_func = NULL; + goto __pyx_L15; + } - /* "View.MemoryView":1082 - * else: - * to_object_func = NULL - * to_dtype_func = NULL # <<<<<<<<<<<<<< + /* "View.MemoryView":841 + * start = shape - 1 + * else: + * start = 0 # <<<<<<<<<<<<<< * - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + * if have_stop: */ - __pyx_v_to_dtype_func = NULL; - } - __pyx_L3:; + /*else*/ { + __pyx_v_start = 0; + } + __pyx_L15:; + } + __pyx_L11:; - /* "View.MemoryView":1084 - * to_dtype_func = NULL + /* "View.MemoryView":843 + * start = 0 * - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< - * to_object_func, to_dtype_func, - * memview.dtype_is_object) + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape */ - __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = (__pyx_v_have_stop != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1086 - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, - * to_object_func, to_dtype_func, - * memview.dtype_is_object) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":844 * + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: */ - __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1084, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1070 - * - * @cname('__pyx_memoryview_copy_object_from_slice') - * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< - * """ - * Create a new memoryview object from a given memoryview object and slice. + /* "View.MemoryView":845 + * if have_stop: + * if stop < 0: + * stop += shape # <<<<<<<<<<<<<< + * if stop < 0: + * stop = 0 */ + __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1092 - * - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< - * if arg < 0: - * return -arg + /* "View.MemoryView":846 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: */ + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { -static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { - Py_ssize_t __pyx_r; - int __pyx_t_1; - - /* "View.MemoryView":1093 - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: # <<<<<<<<<<<<<< - * return -arg - * else: + /* "View.MemoryView":847 + * stop += shape + * if stop < 0: + * stop = 0 # <<<<<<<<<<<<<< + * elif stop > shape: + * stop = shape */ - __pyx_t_1 = ((__pyx_v_arg < 0) != 0); - if (__pyx_t_1) { + __pyx_v_stop = 0; - /* "View.MemoryView":1094 - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: - * return -arg # <<<<<<<<<<<<<< - * else: - * return arg + /* "View.MemoryView":846 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: */ - __pyx_r = (-__pyx_v_arg); - goto __pyx_L0; + } - /* "View.MemoryView":1093 + /* "View.MemoryView":844 * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: # <<<<<<<<<<<<<< - * return -arg - * else: + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: */ - } + goto __pyx_L17; + } - /* "View.MemoryView":1096 - * return -arg - * else: - * return arg # <<<<<<<<<<<<<< - * - * @cname('__pyx_get_best_slice_order') + /* "View.MemoryView":848 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: */ - /*else*/ { - __pyx_r = __pyx_v_arg; - goto __pyx_L0; - } + __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1092 - * - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< - * if arg < 0: - * return -arg + /* "View.MemoryView":849 + * stop = 0 + * elif stop > shape: + * stop = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: */ + __pyx_v_stop = __pyx_v_shape; - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} + /* "View.MemoryView":848 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: + */ + } + __pyx_L17:; -/* "View.MemoryView":1099 + /* "View.MemoryView":843 + * start = 0 * - * @cname('__pyx_get_best_slice_order') - * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< - * """ - * Figure out the best memory access order for a given slice. + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape */ + goto __pyx_L16; + } -static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) { - int __pyx_v_i; - Py_ssize_t __pyx_v_c_stride; - Py_ssize_t __pyx_v_f_stride; - char __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; + /* "View.MemoryView":851 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: + */ + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1104 - * """ - * cdef int i - * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< - * cdef Py_ssize_t f_stride = 0 - * + /* "View.MemoryView":852 + * else: + * if negative_step: + * stop = -1 # <<<<<<<<<<<<<< + * else: + * stop = shape */ - __pyx_v_c_stride = 0; + __pyx_v_stop = -1L; - /* "View.MemoryView":1105 - * cdef int i - * cdef Py_ssize_t c_stride = 0 - * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< - * - * for i in range(ndim - 1, -1, -1): + /* "View.MemoryView":851 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: */ - __pyx_v_f_stride = 0; + goto __pyx_L19; + } - /* "View.MemoryView":1107 - * cdef Py_ssize_t f_stride = 0 + /* "View.MemoryView":854 + * stop = -1 + * else: + * stop = shape # <<<<<<<<<<<<<< * - * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] + * if not have_step: */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { - __pyx_v_i = __pyx_t_1; + /*else*/ { + __pyx_v_stop = __pyx_v_shape; + } + __pyx_L19:; + } + __pyx_L16:; - /* "View.MemoryView":1108 + /* "View.MemoryView":856 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 * - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * c_stride = mslice.strides[i] - * break */ - __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1109 - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< - * break + /* "View.MemoryView":857 + * + * if not have_step: + * step = 1 # <<<<<<<<<<<<<< * - */ - __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1110 - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] - * break # <<<<<<<<<<<<<< * - * for i in range(ndim): */ - goto __pyx_L4_break; + __pyx_v_step = 1; - /* "View.MemoryView":1108 + /* "View.MemoryView":856 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 * - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * c_stride = mslice.strides[i] - * break */ } - } - __pyx_L4_break:; - /* "View.MemoryView":1112 - * break + /* "View.MemoryView":861 * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] + * with cython.cdivision(True): + * new_shape = (stop - start) // step # <<<<<<<<<<<<<< + * + * if (stop - start) - step * new_shape: */ - __pyx_t_1 = __pyx_v_ndim; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); - /* "View.MemoryView":1113 + /* "View.MemoryView":863 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 * - * for i in range(ndim): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * f_stride = mslice.strides[i] - * break */ - __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1114 - * for i in range(ndim): - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< - * break + /* "View.MemoryView":864 * - */ - __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1115 - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] - * break # <<<<<<<<<<<<<< + * if (stop - start) - step * new_shape: + * new_shape += 1 # <<<<<<<<<<<<<< * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + * if new_shape < 0: */ - goto __pyx_L7_break; + __pyx_v_new_shape = (__pyx_v_new_shape + 1); - /* "View.MemoryView":1113 + /* "View.MemoryView":863 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 * - * for i in range(ndim): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * f_stride = mslice.strides[i] - * break */ } - } - __pyx_L7_break:; - /* "View.MemoryView":1117 - * break + /* "View.MemoryView":866 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< - * return 'C' - * else: */ - __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); - if (__pyx_t_2) { + __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1118 + /* "View.MemoryView":867 + * + * if new_shape < 0: + * new_shape = 0 # <<<<<<<<<<<<<< + * * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): - * return 'C' # <<<<<<<<<<<<<< - * else: - * return 'F' */ - __pyx_r = 'C'; - goto __pyx_L0; + __pyx_v_new_shape = 0; - /* "View.MemoryView":1117 - * break + /* "View.MemoryView":866 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< - * return 'C' - * else: */ - } + } - /* "View.MemoryView":1120 - * return 'C' - * else: - * return 'F' # <<<<<<<<<<<<<< + /* "View.MemoryView":870 * - * @cython.cdivision(True) + * + * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset */ - /*else*/ { - __pyx_r = 'F'; - goto __pyx_L0; - } + (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); - /* "View.MemoryView":1099 + /* "View.MemoryView":871 + * + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< + * dst.suboffsets[new_ndim] = suboffset * - * @cname('__pyx_get_best_slice_order') - * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< - * """ - * Figure out the best memory access order for a given slice. */ + (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1123 + /* "View.MemoryView":872 + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< + * * - * @cython.cdivision(True) - * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< - * char *dst_data, Py_ssize_t *dst_strides, - * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, */ + (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset; + } + __pyx_L3:; -static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) { - CYTHON_UNUSED Py_ssize_t __pyx_v_i; - CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent; - Py_ssize_t __pyx_v_dst_extent; - Py_ssize_t __pyx_v_src_stride; - Py_ssize_t __pyx_v_dst_stride; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - Py_ssize_t __pyx_t_4; - Py_ssize_t __pyx_t_5; - - /* "View.MemoryView":1130 + /* "View.MemoryView":875 * - * cdef Py_ssize_t i - * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] + * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: */ - __pyx_v_src_extent = (__pyx_v_src_shape[0]); + __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1131 - * cdef Py_ssize_t i - * cdef Py_ssize_t src_extent = src_shape[0] - * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t src_stride = src_strides[0] - * cdef Py_ssize_t dst_stride = dst_strides[0] + /* "View.MemoryView":876 + * + * if suboffset_dim[0] < 0: + * dst.data += start * stride # <<<<<<<<<<<<<< + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride */ - __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); + __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride)); - /* "View.MemoryView":1132 - * cdef Py_ssize_t src_extent = src_shape[0] - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t dst_stride = dst_strides[0] + /* "View.MemoryView":875 + * * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: */ - __pyx_v_src_stride = (__pyx_v_src_strides[0]); + goto __pyx_L23; + } - /* "View.MemoryView":1133 - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] - * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< + /* "View.MemoryView":878 + * dst.data += start * stride + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< * - * if ndim == 1: + * if suboffset >= 0: */ - __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); + /*else*/ { + __pyx_t_3 = (__pyx_v_suboffset_dim[0]); + (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride)); + } + __pyx_L23:; - /* "View.MemoryView":1135 - * cdef Py_ssize_t dst_stride = dst_strides[0] + /* "View.MemoryView":880 + * dst.suboffsets[suboffset_dim[0]] += start * stride * - * if ndim == 1: # <<<<<<<<<<<<<< - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: */ - __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); - if (__pyx_t_1) { + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1136 + /* "View.MemoryView":881 * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset */ - __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L5_bool_binop_done; - } - __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); + __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L5_bool_binop_done; - } - /* "View.MemoryView":1137 - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< - * memcpy(dst_data, src_data, itemsize * dst_extent) - * else: + /* "View.MemoryView":882 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: */ - __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize); - if (__pyx_t_2) { - __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride)); - } - __pyx_t_3 = (__pyx_t_2 != 0); - __pyx_t_1 = __pyx_t_3; - __pyx_L5_bool_binop_done:; + __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1136 - * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) + /* "View.MemoryView":883 + * if not is_slice: + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " */ - if (__pyx_t_1) { + __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset); - /* "View.MemoryView":1138 - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< - * else: - * for i in range(dst_extent): + /* "View.MemoryView":882 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: */ - memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)); + goto __pyx_L26; + } - /* "View.MemoryView":1136 + /* "View.MemoryView":885 + * dst.data = ( dst.data)[0] + suboffset + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< + * "must be indexed and not sliced", dim) + * else: + */ + /*else*/ { + + /* "View.MemoryView":886 + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " + * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<< + * else: + * suboffset_dim[0] = new_ndim + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 885, __pyx_L1_error) + } + __pyx_L26:; + + /* "View.MemoryView":881 * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset */ - goto __pyx_L4; + goto __pyx_L25; } - /* "View.MemoryView":1140 - * memcpy(dst_data, src_data, itemsize * dst_extent) - * else: - * for i in range(dst_extent): # <<<<<<<<<<<<<< - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride + /* "View.MemoryView":888 + * "must be indexed and not sliced", dim) + * else: + * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< + * + * return 0 */ /*else*/ { - __pyx_t_4 = __pyx_v_dst_extent; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim; + } + __pyx_L25:; - /* "View.MemoryView":1141 - * else: - * for i in range(dst_extent): - * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< - * src_data += src_stride - * dst_data += dst_stride + /* "View.MemoryView":880 + * dst.suboffsets[suboffset_dim[0]] += start * stride + * + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: */ - memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize); + } - /* "View.MemoryView":1142 - * for i in range(dst_extent): - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride # <<<<<<<<<<<<<< - * dst_data += dst_stride - * else: + /* "View.MemoryView":890 + * suboffset_dim[0] = new_ndim + * + * return 0 # <<<<<<<<<<<<<< + * + * */ - __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + __pyx_r = 0; + goto __pyx_L0; - /* "View.MemoryView":1143 - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride - * dst_data += dst_stride # <<<<<<<<<<<<<< + /* "View.MemoryView":793 + * + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":896 + * + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + */ + +static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) { + Py_ssize_t __pyx_v_shape; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_suboffset; + Py_ssize_t __pyx_v_itemsize; + char *__pyx_v_resultp; + char *__pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("pybuffer_index", 0); + + /* "View.MemoryView":898 + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< + * cdef Py_ssize_t itemsize = view.itemsize + * cdef char *resultp + */ + __pyx_v_suboffset = -1L; + + /* "View.MemoryView":899 + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< + * cdef char *resultp + * + */ + __pyx_t_1 = __pyx_v_view->itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":902 + * cdef char *resultp + * + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize + */ + __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":903 + * + * if view.ndim == 0: + * shape = view.len / itemsize # <<<<<<<<<<<<<< + * stride = itemsize * else: - * for i in range(dst_extent): */ - __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); - } + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(2, 903, __pyx_L1_error) } - __pyx_L4:; + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(2, 903, __pyx_L1_error) + } + __pyx_v_shape = (__pyx_v_view->len / __pyx_v_itemsize); - /* "View.MemoryView":1135 - * cdef Py_ssize_t dst_stride = dst_strides[0] + /* "View.MemoryView":904 + * if view.ndim == 0: + * shape = view.len / itemsize + * stride = itemsize # <<<<<<<<<<<<<< + * else: + * shape = view.shape[dim] + */ + __pyx_v_stride = __pyx_v_itemsize; + + /* "View.MemoryView":902 + * cdef char *resultp * - * if ndim == 1: # <<<<<<<<<<<<<< - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize */ goto __pyx_L3; } - /* "View.MemoryView":1145 - * dst_data += dst_stride + /* "View.MemoryView":906 + * stride = itemsize * else: - * for i in range(dst_extent): # <<<<<<<<<<<<<< - * _copy_strided_to_strided(src_data, src_strides + 1, - * dst_data, dst_strides + 1, + * shape = view.shape[dim] # <<<<<<<<<<<<<< + * stride = view.strides[dim] + * if view.suboffsets != NULL: */ /*else*/ { - __pyx_t_4 = __pyx_v_dst_extent; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); - /* "View.MemoryView":1146 + /* "View.MemoryView":907 * else: - * for i in range(dst_extent): - * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< - * dst_data, dst_strides + 1, - * src_shape + 1, dst_shape + 1, + * shape = view.shape[dim] + * stride = view.strides[dim] # <<<<<<<<<<<<<< + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] */ - _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); + __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); - /* "View.MemoryView":1150 - * src_shape + 1, dst_shape + 1, - * ndim - 1, itemsize) - * src_data += src_stride # <<<<<<<<<<<<<< - * dst_data += dst_stride + /* "View.MemoryView":908 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] * */ - __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1151 - * ndim - 1, itemsize) - * src_data += src_stride - * dst_data += dst_stride # <<<<<<<<<<<<<< + /* "View.MemoryView":909 + * stride = view.strides[dim] + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< + * + * if index < 0: + */ + __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]); + + /* "View.MemoryView":908 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, */ - __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); } } __pyx_L3:; - /* "View.MemoryView":1123 + /* "View.MemoryView":911 + * suboffset = view.suboffsets[dim] * - * @cython.cdivision(True) - * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< - * char *dst_data, Py_ssize_t *dst_strides, - * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: */ + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (__pyx_t_2) { - /* function exit code */ -} - -/* "View.MemoryView":1153 - * dst_data += dst_stride + /* "View.MemoryView":912 * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: + * if index < 0: + * index += view.shape[dim] # <<<<<<<<<<<<<< + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) */ + __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); -static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { - - /* "View.MemoryView":1156 - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: - * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< - * src.shape, dst.shape, ndim, itemsize) + /* "View.MemoryView":913 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * */ - _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1153 - * dst_data += dst_stride + /* "View.MemoryView":914 + * index += view.shape[dim] + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: + * if index >= shape: */ + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(2, 914, __pyx_L1_error) - /* function exit code */ -} - -/* "View.MemoryView":1160 - * - * @cname('__pyx_memoryview_slice_get_size') - * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef int i - */ - -static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) { - int __pyx_v_i; - Py_ssize_t __pyx_v_size; - Py_ssize_t __pyx_r; - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - - /* "View.MemoryView":1163 - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef int i - * cdef Py_ssize_t size = src.memview.view.itemsize # <<<<<<<<<<<<<< + /* "View.MemoryView":913 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * for i in range(ndim): */ - __pyx_t_1 = __pyx_v_src->memview->view.itemsize; - __pyx_v_size = __pyx_t_1; + } - /* "View.MemoryView":1165 - * cdef Py_ssize_t size = src.memview.view.itemsize - * - * for i in range(ndim): # <<<<<<<<<<<<<< - * size *= src.shape[i] + /* "View.MemoryView":911 + * suboffset = view.suboffsets[dim] * + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: */ - __pyx_t_2 = __pyx_v_ndim; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + } - /* "View.MemoryView":1166 + /* "View.MemoryView":916 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * for i in range(ndim): - * size *= src.shape[i] # <<<<<<<<<<<<<< + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * return size */ - __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i])); - } + __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1168 - * size *= src.shape[i] + /* "View.MemoryView":917 * - * return size # <<<<<<<<<<<<<< + * if index >= shape: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< * - * @cname('__pyx_fill_contig_strides_array') + * resultp = bufp + index * stride */ - __pyx_r = __pyx_v_size; - goto __pyx_L0; + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 917, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 917, __pyx_L1_error) - /* "View.MemoryView":1160 + /* "View.MemoryView":916 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * @cname('__pyx_memoryview_slice_get_size') - * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef int i - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1171 + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * @cname('__pyx_fill_contig_strides_array') - * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< - * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, - * int ndim, char order) nogil: */ + } -static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) { - int __pyx_v_idx; - Py_ssize_t __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - - /* "View.MemoryView":1180 - * cdef int idx + /* "View.MemoryView":919 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * - * if order == 'F': # <<<<<<<<<<<<<< - * for idx in range(ndim): - * strides[idx] = stride + * resultp = bufp + index * stride # <<<<<<<<<<<<<< + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset */ - __pyx_t_1 = ((__pyx_v_order == 'F') != 0); - if (__pyx_t_1) { + __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); - /* "View.MemoryView":1181 + /* "View.MemoryView":920 * - * if order == 'F': - * for idx in range(ndim): # <<<<<<<<<<<<<< - * strides[idx] = stride - * stride = stride * shape[idx] - */ - __pyx_t_2 = __pyx_v_ndim; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_idx = __pyx_t_3; - - /* "View.MemoryView":1182 - * if order == 'F': - * for idx in range(ndim): - * strides[idx] = stride # <<<<<<<<<<<<<< - * stride = stride * shape[idx] - * else: - */ - (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; - - /* "View.MemoryView":1183 - * for idx in range(ndim): - * strides[idx] = stride - * stride = stride * shape[idx] # <<<<<<<<<<<<<< - * else: - * for idx in range(ndim - 1, -1, -1): - */ - __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); - } - - /* "View.MemoryView":1180 - * cdef int idx + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset * - * if order == 'F': # <<<<<<<<<<<<<< - * for idx in range(ndim): - * strides[idx] = stride */ - goto __pyx_L3; - } - - /* "View.MemoryView":1185 - * stride = stride * shape[idx] - * else: - * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * strides[idx] = stride - * stride = stride * shape[idx] - */ - /*else*/ { - for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) { - __pyx_v_idx = __pyx_t_2; + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1186 - * else: - * for idx in range(ndim - 1, -1, -1): - * strides[idx] = stride # <<<<<<<<<<<<<< - * stride = stride * shape[idx] + /* "View.MemoryView":921 + * resultp = bufp + index * stride + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< * + * return resultp */ - (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; + __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset); - /* "View.MemoryView":1187 - * for idx in range(ndim - 1, -1, -1): - * strides[idx] = stride - * stride = stride * shape[idx] # <<<<<<<<<<<<<< + /* "View.MemoryView":920 + * + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset * - * return stride */ - __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); - } } - __pyx_L3:; - /* "View.MemoryView":1189 - * stride = stride * shape[idx] + /* "View.MemoryView":923 + * resultp = ( resultp)[0] + suboffset + * + * return resultp # <<<<<<<<<<<<<< * - * return stride # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_copy_data_to_temp') */ - __pyx_r = __pyx_v_stride; + __pyx_r = __pyx_v_resultp; goto __pyx_L0; - /* "View.MemoryView":1171 + /* "View.MemoryView":896 * - * @cname('__pyx_fill_contig_strides_array') - * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< - * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, - * int ndim, char order) nogil: + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 */ /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":1192 +/* "View.MemoryView":929 + * + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim * - * @cname('__pyx_memoryview_copy_data_to_temp') - * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *tmpslice, - * char order, */ -static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) { - int __pyx_v_i; - void *__pyx_v_result; - size_t __pyx_v_itemsize; - size_t __pyx_v_size; - void *__pyx_r; - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - struct __pyx_memoryview_obj *__pyx_t_4; - int __pyx_t_5; +static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { + int __pyx_v_ndim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_r; + int __pyx_t_1; + Py_ssize_t *__pyx_t_2; + long __pyx_t_3; + Py_ssize_t __pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; - /* "View.MemoryView":1203 - * cdef void *result - * - * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< - * cdef size_t size = slice_get_size(src, ndim) + /* "View.MemoryView":930 + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: + * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< * + * cdef Py_ssize_t *shape = memslice.shape */ - __pyx_t_1 = __pyx_v_src->memview->view.itemsize; - __pyx_v_itemsize = __pyx_t_1; + __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; + __pyx_v_ndim = __pyx_t_1; - /* "View.MemoryView":1204 + /* "View.MemoryView":932 + * cdef int ndim = memslice.memview.view.ndim * - * cdef size_t itemsize = src.memview.view.itemsize - * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< + * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< + * cdef Py_ssize_t *strides = memslice.strides * - * result = malloc(size) */ - __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); + __pyx_t_2 = __pyx_v_memslice->shape; + __pyx_v_shape = __pyx_t_2; - /* "View.MemoryView":1206 - * cdef size_t size = slice_get_size(src, ndim) + /* "View.MemoryView":933 * - * result = malloc(size) # <<<<<<<<<<<<<< - * if not result: - * _err(MemoryError, NULL) - */ - __pyx_v_result = malloc(__pyx_v_size); - - /* "View.MemoryView":1207 + * cdef Py_ssize_t *shape = memslice.shape + * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< * - * result = malloc(size) - * if not result: # <<<<<<<<<<<<<< - * _err(MemoryError, NULL) * */ - __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); - if (__pyx_t_2) { + __pyx_t_2 = __pyx_v_memslice->strides; + __pyx_v_strides = __pyx_t_2; - /* "View.MemoryView":1208 - * result = malloc(size) - * if not result: - * _err(MemoryError, NULL) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":937 * + * cdef int i, j + * for i in range(ndim / 2): # <<<<<<<<<<<<<< + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] */ - __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 1208, __pyx_L1_error) + __pyx_t_3 = (__pyx_v_ndim / 2); + for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) { + __pyx_v_i = __pyx_t_1; - /* "View.MemoryView":1207 - * - * result = malloc(size) - * if not result: # <<<<<<<<<<<<<< - * _err(MemoryError, NULL) - * + /* "View.MemoryView":938 + * cdef int i, j + * for i in range(ndim / 2): + * j = ndim - 1 - i # <<<<<<<<<<<<<< + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] */ - } + __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); - /* "View.MemoryView":1211 - * + /* "View.MemoryView":939 + * for i in range(ndim / 2): + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< + * shape[i], shape[j] = shape[j], shape[i] * - * tmpslice.data = result # <<<<<<<<<<<<<< - * tmpslice.memview = src.memview - * for i in range(ndim): */ - __pyx_v_tmpslice->data = ((char *)__pyx_v_result); + __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]); + __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]); + (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4; + (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5; - /* "View.MemoryView":1212 + /* "View.MemoryView":940 + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< * - * tmpslice.data = result - * tmpslice.memview = src.memview # <<<<<<<<<<<<<< - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] - */ - __pyx_t_4 = __pyx_v_src->memview; - __pyx_v_tmpslice->memview = __pyx_t_4; - - /* "View.MemoryView":1213 - * tmpslice.data = result - * tmpslice.memview = src.memview - * for i in range(ndim): # <<<<<<<<<<<<<< - * tmpslice.shape[i] = src.shape[i] - * tmpslice.suboffsets[i] = -1 + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: */ - __pyx_t_3 = __pyx_v_ndim; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]); + __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]); + (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5; + (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4; - /* "View.MemoryView":1214 - * tmpslice.memview = src.memview - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< - * tmpslice.suboffsets[i] = -1 + /* "View.MemoryView":942 + * shape[i], shape[j] = shape[j], shape[i] * - */ - (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); - - /* "View.MemoryView":1215 - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] - * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") * - * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, */ - (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; - } + __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L6_bool_binop_done:; + if (__pyx_t_6) { - /* "View.MemoryView":1217 - * tmpslice.suboffsets[i] = -1 + /* "View.MemoryView":943 * - * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< - * ndim, order) + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< * + * return 1 */ - __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order); + __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 943, __pyx_L1_error) - /* "View.MemoryView":1221 + /* "View.MemoryView":942 + * shape[i], shape[j] = shape[j], shape[i] * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if tmpslice.shape[i] == 1: - * tmpslice.strides[i] = 0 */ - __pyx_t_3 = __pyx_v_ndim; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + } + } - /* "View.MemoryView":1222 + /* "View.MemoryView":945 + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") * - * for i in range(ndim): - * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< - * tmpslice.strides[i] = 0 + * return 1 # <<<<<<<<<<<<<< * - */ - __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1223 - * for i in range(ndim): - * if tmpslice.shape[i] == 1: - * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< * - * if slice_is_contig(src[0], order, ndim): */ - (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0; + __pyx_r = 1; + goto __pyx_L0; - /* "View.MemoryView":1222 + /* "View.MemoryView":929 * - * for i in range(ndim): - * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< - * tmpslice.strides[i] = 0 + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim * */ - } + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif } + __pyx_r = 0; + __pyx_L0:; + return __pyx_r; +} - /* "View.MemoryView":1225 - * tmpslice.strides[i] = 0 +/* "View.MemoryView":962 + * cdef int (*to_dtype_func)(char *, object) except 0 * - * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< - * memcpy(result, src.data, size) - * else: - */ - __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1226 + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) * - * if slice_is_contig(src[0], order, ndim): - * memcpy(result, src.data, size) # <<<<<<<<<<<<<< - * else: - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) */ - memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size); - /* "View.MemoryView":1225 - * tmpslice.strides[i] = 0 - * - * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< - * memcpy(result, src.data, size) - * else: - */ - goto __pyx_L9; - } +/* Python wrapper */ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - /* "View.MemoryView":1228 - * memcpy(result, src.data, size) - * else: - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< - * - * return result - */ - /*else*/ { - copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize); - } - __pyx_L9:; + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} - /* "View.MemoryView":1230 - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) - * - * return result # <<<<<<<<<<<<<< +static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":963 * + * def __dealloc__(self): + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< * + * cdef convert_item_to_object(self, char *itemp): */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; + __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); - /* "View.MemoryView":1192 + /* "View.MemoryView":962 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) * - * @cname('__pyx_memoryview_copy_data_to_temp') - * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *tmpslice, - * char order, */ /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = NULL; - __pyx_L0:; - return __pyx_r; + __Pyx_RefNannyFinishContext(); } -/* "View.MemoryView":1235 +/* "View.MemoryView":965 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) * - * @cname('__pyx_memoryview_err_extents') - * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) */ -static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) { - int __pyx_r; +static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err_extents", 0); + __Pyx_RefNannySetupContext("convert_item_to_object", 0); - /* "View.MemoryView":1238 - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % - * (i, extent1, extent2)) # <<<<<<<<<<<<<< + /* "View.MemoryView":966 * - * @cname('__pyx_memoryview_err_dim') + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_3 = 0; + __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1237 - * cdef int _err_extents(int i, Py_ssize_t extent1, - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< - * (i, extent1, extent2)) + /* "View.MemoryView":967 + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) # <<<<<<<<<<<<<< + * else: + * return memoryview.convert_item_to_object(self, itemp) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 967, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":966 * + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: */ - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 1237, __pyx_L1_error) + } - /* "View.MemoryView":1235 + /* "View.MemoryView":969 + * return self.to_object_func(itemp) + * else: + * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_err_extents') - * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + * cdef assign_item_from_object(self, char *itemp, object value): + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 969, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":965 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif return __pyx_r; } -/* "View.MemoryView":1241 - * - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii') % dim) +/* "View.MemoryView":971 + * return memoryview.convert_item_to_object(self, itemp) * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) */ -static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) { - int __pyx_r; +static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_1; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err_dim", 0); - __Pyx_INCREF(__pyx_v_error); + __Pyx_RefNannySetupContext("assign_item_from_object", 0); - /* "View.MemoryView":1242 - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: - * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< + /* "View.MemoryView":972 * - * @cname('__pyx_memoryview_err') + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: */ - __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_error); - __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1242, __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 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":973 + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< + * else: + * memoryview.assign_item_from_object(self, itemp, value) + */ + __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(2, 973, __pyx_L1_error) + + /* "View.MemoryView":972 + * + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: + */ + goto __pyx_L3; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(2, 1242, __pyx_L1_error) - /* "View.MemoryView":1241 + /* "View.MemoryView":975 + * self.to_dtype_func(itemp, value) + * else: + * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii') % dim) + * @property + */ + /*else*/ { + __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 975, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":971 + * return memoryview.convert_item_to_object(self, itemp) * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_XDECREF(__pyx_v_error); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif return __pyx_r; } -/* "View.MemoryView":1245 +/* "View.MemoryView":978 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object * - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< - * if msg != NULL: - * raise error(msg.decode('ascii')) */ -static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { - int __pyx_r; +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err", 0); - __Pyx_INCREF(__pyx_v_error); - - /* "View.MemoryView":1246 - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii')) - * else: - */ - __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); - if (__pyx_t_1) { + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - /* "View.MemoryView":1247 - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: - * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< - * else: - * raise error - */ - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_error); - __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(2, 1247, __pyx_L1_error) + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":1246 - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii')) - * else: - */ - } +static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":1249 - * raise error(msg.decode('ascii')) - * else: - * raise error # <<<<<<<<<<<<<< + /* "View.MemoryView":979 + * @property + * def base(self): + * return self.from_object # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_copy_contents') + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") */ - /*else*/ { - __Pyx_Raise(__pyx_v_error, 0, 0, 0); - __PYX_ERR(2, 1249, __pyx_L1_error) - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->from_object); + __pyx_r = __pyx_v_self->from_object; + goto __pyx_L0; - /* "View.MemoryView":1245 + /* "View.MemoryView":978 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object * - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< - * if msg != NULL: - * raise error(msg.decode('ascii')) */ /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_XDECREF(__pyx_v_error); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif return __pyx_r; } -/* "View.MemoryView":1252 +/* "View.MemoryView":985 * - * @cname('__pyx_memoryview_copy_contents') - * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice dst, - * int src_ndim, int dst_ndim, + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), */ -static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) { - void *__pyx_v_tmpdata; - size_t __pyx_v_itemsize; - int __pyx_v_i; - char __pyx_v_order; - int __pyx_v_broadcasting; - int __pyx_v_direct_copy; - __Pyx_memviewslice __pyx_v_tmp; - int __pyx_v_ndim; - int __pyx_r; - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - void *__pyx_t_6; - int __pyx_t_7; - - /* "View.MemoryView":1260 - * Check for overlapping memory and verify the shapes. - * """ - * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< - * cdef size_t itemsize = src.memview.view.itemsize - * cdef int i - */ - __pyx_v_tmpdata = NULL; +static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TypeInfo *__pyx_t_4; + Py_buffer __pyx_t_5; + Py_ssize_t *__pyx_t_6; + Py_ssize_t *__pyx_t_7; + Py_ssize_t *__pyx_t_8; + Py_ssize_t __pyx_t_9; + __Pyx_RefNannySetupContext("memoryview_fromslice", 0); - /* "View.MemoryView":1261 - * """ - * cdef void *tmpdata = NULL - * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) - */ - __pyx_t_1 = __pyx_v_src.memview->view.itemsize; - __pyx_v_itemsize = __pyx_t_1; - - /* "View.MemoryView":1263 - * cdef size_t itemsize = src.memview.view.itemsize - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< - * cdef bint broadcasting = False - * cdef bint direct_copy = False - */ - __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); - - /* "View.MemoryView":1264 - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) - * cdef bint broadcasting = False # <<<<<<<<<<<<<< - * cdef bint direct_copy = False - * cdef __Pyx_memviewslice tmp - */ - __pyx_v_broadcasting = 0; - - /* "View.MemoryView":1265 - * cdef char order = get_best_order(&src, src_ndim) - * cdef bint broadcasting = False - * cdef bint direct_copy = False # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice tmp + /* "View.MemoryView":993 + * cdef _memoryviewslice result * - */ - __pyx_v_direct_copy = 0; - - /* "View.MemoryView":1268 - * cdef __Pyx_memviewslice tmp + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None * - * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: */ - __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); - if (__pyx_t_2) { + __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1269 + /* "View.MemoryView":994 + * + * if memviewslice.memview == Py_None: + * return None # <<<<<<<<<<<<<< + * * - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< - * elif dst_ndim < src_ndim: - * broadcast_leading(&dst, dst_ndim, src_ndim) */ - __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; - /* "View.MemoryView":1268 - * cdef __Pyx_memviewslice tmp + /* "View.MemoryView":993 + * cdef _memoryviewslice result + * + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None * - * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: */ - goto __pyx_L3; } - /* "View.MemoryView":1270 - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&dst, dst_ndim, src_ndim) + /* "View.MemoryView":999 + * * + * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< + * + * result.from_slice = memviewslice */ - __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); - if (__pyx_t_2) { + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 999, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); + __pyx_t_2 = 0; - /* "View.MemoryView":1271 - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: - * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< + /* "View.MemoryView":1001 + * result = _memoryviewslice(None, 0, dtype_is_object) + * + * result.from_slice = memviewslice # <<<<<<<<<<<<<< + * __PYX_INC_MEMVIEW(&memviewslice, 1) * - * cdef int ndim = max(src_ndim, dst_ndim) */ - __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim); + __pyx_v_result->from_slice = __pyx_v_memviewslice; - /* "View.MemoryView":1270 - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&dst, dst_ndim, src_ndim) + /* "View.MemoryView":1002 + * + * result.from_slice = memviewslice + * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< * + * result.from_object = ( memviewslice.memview).base */ - } - __pyx_L3:; + __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); - /* "View.MemoryView":1273 - * broadcast_leading(&dst, dst_ndim, src_ndim) + /* "View.MemoryView":1004 + * __PYX_INC_MEMVIEW(&memviewslice, 1) * - * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< + * result.typeinfo = memviewslice.memview.typeinfo * - * for i in range(ndim): */ - __pyx_t_3 = __pyx_v_dst_ndim; - __pyx_t_4 = __pyx_v_src_ndim; - if (((__pyx_t_3 > __pyx_t_4) != 0)) { - __pyx_t_5 = __pyx_t_3; - } else { - __pyx_t_5 = __pyx_t_4; - } - __pyx_v_ndim = __pyx_t_5; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1004, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_result->from_object); + __Pyx_DECREF(__pyx_v_result->from_object); + __pyx_v_result->from_object = __pyx_t_2; + __pyx_t_2 = 0; - /* "View.MemoryView":1275 - * cdef int ndim = max(src_ndim, dst_ndim) + /* "View.MemoryView":1005 * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: + * result.from_object = ( memviewslice.memview).base + * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< + * + * result.view = memviewslice.memview.view */ - __pyx_t_5 = __pyx_v_ndim; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; + __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; - /* "View.MemoryView":1276 + /* "View.MemoryView":1007 + * result.typeinfo = memviewslice.memview.typeinfo * - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< - * if src.shape[i] == 1: - * broadcasting = True + * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< + * result.view.buf = memviewslice.data + * result.view.ndim = ndim */ - __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); - if (__pyx_t_2) { + __pyx_t_5 = __pyx_v_memviewslice.memview->view; + __pyx_v_result->__pyx_base.view = __pyx_t_5; - /* "View.MemoryView":1277 - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: # <<<<<<<<<<<<<< - * broadcasting = True - * src.strides[i] = 0 + /* "View.MemoryView":1008 + * + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None */ - __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); - if (__pyx_t_2) { + __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); - /* "View.MemoryView":1278 - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: - * broadcasting = True # <<<<<<<<<<<<<< - * src.strides[i] = 0 - * else: + /* "View.MemoryView":1009 + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data + * result.view.ndim = ndim # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) */ - __pyx_v_broadcasting = 1; + __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; - /* "View.MemoryView":1279 - * if src.shape[i] == 1: - * broadcasting = True - * src.strides[i] = 0 # <<<<<<<<<<<<<< - * else: - * _err_extents(i, dst.shape[i], src.shape[i]) + /* "View.MemoryView":1010 + * result.view.buf = memviewslice.data + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * */ - (__pyx_v_src.strides[__pyx_v_i]) = 0; + ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; - /* "View.MemoryView":1277 - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: # <<<<<<<<<<<<<< - * broadcasting = True - * src.strides[i] = 0 + /* "View.MemoryView":1011 + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * result.flags = PyBUF_RECORDS */ - goto __pyx_L7; - } + Py_INCREF(Py_None); - /* "View.MemoryView":1281 - * src.strides[i] = 0 - * else: - * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< + /* "View.MemoryView":1013 + * Py_INCREF(Py_None) * - * if src.suboffsets[i] >= 0: + * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< + * + * result.view.shape = result.from_slice.shape */ - /*else*/ { - __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1281, __pyx_L1_error) - } - __pyx_L7:; + __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; - /* "View.MemoryView":1276 + /* "View.MemoryView":1015 + * result.flags = PyBUF_RECORDS + * + * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< + * result.view.strides = result.from_slice.strides * - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< - * if src.shape[i] == 1: - * broadcasting = True */ - } + __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); - /* "View.MemoryView":1283 - * _err_extents(i, dst.shape[i], src.shape[i]) + /* "View.MemoryView":1016 + * + * result.view.shape = result.from_slice.shape + * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< * - * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Dimension %d is not direct", i) * */ - __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); - if (__pyx_t_2) { + __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); - /* "View.MemoryView":1284 + /* "View.MemoryView":1019 * - * if src.suboffsets[i] >= 0: - * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< * - * if slices_overlap(&src, &dst, ndim, itemsize): + * result.view.suboffsets = NULL # <<<<<<<<<<<<<< + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: */ - __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1284, __pyx_L1_error) + __pyx_v_result->__pyx_base.view.suboffsets = NULL; - /* "View.MemoryView":1283 - * _err_extents(i, dst.shape[i], src.shape[i]) - * - * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Dimension %d is not direct", i) + /* "View.MemoryView":1020 * + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets */ - } - } + __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_v_suboffset = (__pyx_t_6[0]); - /* "View.MemoryView":1286 - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< - * - * if not slice_is_contig(src, order, ndim): + /* "View.MemoryView":1021 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break */ - __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); - if (__pyx_t_2) { + __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":1288 - * if slices_overlap(&src, &dst, ndim, itemsize): - * - * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< - * order = get_best_order(&dst, ndim) + /* "View.MemoryView":1022 + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< + * break * */ - __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0); - if (__pyx_t_2) { + __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); - /* "View.MemoryView":1289 - * - * if not slice_is_contig(src, order, ndim): - * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< + /* "View.MemoryView":1023 + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets + * break # <<<<<<<<<<<<<< * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + * result.view.len = result.view.itemsize */ - __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim); + goto __pyx_L5_break; - /* "View.MemoryView":1288 - * if slices_overlap(&src, &dst, ndim, itemsize): - * - * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< - * order = get_best_order(&dst, ndim) - * + /* "View.MemoryView":1021 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break */ } + } + __pyx_L5_break:; - /* "View.MemoryView":1291 - * order = get_best_order(&dst, ndim) - * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< - * src = tmp + /* "View.MemoryView":1025 + * break * + * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< + * for length in result.view.shape[:ndim]: + * result.view.len *= length */ - __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 1291, __pyx_L1_error) - __pyx_v_tmpdata = __pyx_t_6; + __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; - /* "View.MemoryView":1292 + /* "View.MemoryView":1026 * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) - * src = tmp # <<<<<<<<<<<<<< + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< + * result.view.len *= length * - * if not broadcasting: */ - __pyx_v_src = __pyx_v_tmp; + __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1026, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); + __pyx_t_2 = 0; - /* "View.MemoryView":1286 - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + /* "View.MemoryView":1027 + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: + * result.view.len *= length # <<<<<<<<<<<<<< * - * if not slice_is_contig(src, order, ndim): + * result.to_object_func = to_object_func */ + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 1027, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; } - /* "View.MemoryView":1294 - * src = tmp - * - * if not broadcasting: # <<<<<<<<<<<<<< + /* "View.MemoryView":1029 + * result.view.len *= length * + * result.to_object_func = to_object_func # <<<<<<<<<<<<<< + * result.to_dtype_func = to_dtype_func * */ - __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); - if (__pyx_t_2) { + __pyx_v_result->to_object_func = __pyx_v_to_object_func; - /* "View.MemoryView":1297 - * + /* "View.MemoryView":1030 * - * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): - */ - __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1298 + * result.to_object_func = to_object_func + * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< * - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<< - * elif slice_is_contig(src, 'F', ndim): - * direct_copy = slice_is_contig(dst, 'F', ndim) + * return result */ - __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim); + __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; - /* "View.MemoryView":1297 + /* "View.MemoryView":1032 + * result.to_dtype_func = to_dtype_func * + * return result # <<<<<<<<<<<<<< * - * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): + * @cname('__pyx_memoryview_get_slice_from_memoryview') */ - goto __pyx_L12; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; - /* "View.MemoryView":1299 - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'F', ndim) + /* "View.MemoryView":985 * + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), */ - __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0); - if (__pyx_t_2) { - /* "View.MemoryView":1300 - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): - * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<< - * - * if direct_copy: - */ - __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim); + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":1299 - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'F', ndim) +/* "View.MemoryView":1035 * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj */ - } - __pyx_L12:; - /* "View.MemoryView":1302 - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - * if direct_copy: # <<<<<<<<<<<<<< - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - */ - __pyx_t_2 = (__pyx_v_direct_copy != 0); - if (__pyx_t_2) { +static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) { + struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0; + __Pyx_memviewslice *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_slice_from_memview", 0); - /* "View.MemoryView":1304 - * if direct_copy: - * - * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) + /* "View.MemoryView":1038 + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1305 - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) + /* "View.MemoryView":1039 + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): + * obj = memview # <<<<<<<<<<<<<< + * return &obj.from_slice + * else: */ - memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)); + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 1039, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; - /* "View.MemoryView":1306 - * refcount_copying(&dst, dtype_is_object, ndim, False) - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< - * free(tmpdata) - * return 0 + /* "View.MemoryView":1040 + * if isinstance(memview, _memoryviewslice): + * obj = memview + * return &obj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, mslice) */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + __pyx_r = (&__pyx_v_obj->from_slice); + goto __pyx_L0; - /* "View.MemoryView":1307 - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) # <<<<<<<<<<<<<< - * return 0 - * + /* "View.MemoryView":1038 + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice */ - free(__pyx_v_tmpdata); + } - /* "View.MemoryView":1308 - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) - * return 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":1042 + * return &obj.from_slice + * else: + * slice_copy(memview, mslice) # <<<<<<<<<<<<<< + * return mslice * - * if order == 'F' == get_best_order(&dst, ndim): */ - __pyx_r = 0; - goto __pyx_L0; + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); - /* "View.MemoryView":1302 - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - * if direct_copy: # <<<<<<<<<<<<<< + /* "View.MemoryView":1043 + * else: + * slice_copy(memview, mslice) + * return mslice # <<<<<<<<<<<<<< * - * refcount_copying(&dst, dtype_is_object, ndim, False) + * @cname('__pyx_memoryview_slice_copy') */ - } + __pyx_r = __pyx_v_mslice; + goto __pyx_L0; + } - /* "View.MemoryView":1294 - * src = tmp - * - * if not broadcasting: # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1035 * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice): + * cdef _memoryviewslice obj */ - } - /* "View.MemoryView":1310 - * return 0 - * - * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< - * + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_obj); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1046 * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets */ - __pyx_t_2 = (__pyx_v_order == 'F'); - if (__pyx_t_2) { - __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim)); - } - __pyx_t_7 = (__pyx_t_2 != 0); - if (__pyx_t_7) { - /* "View.MemoryView":1313 - * - * - * transpose_memslice(&src) # <<<<<<<<<<<<<< - * transpose_memslice(&dst) +static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) { + int __pyx_v_dim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + Py_ssize_t *__pyx_v_suboffsets; + __Pyx_RefNannyDeclarations + Py_ssize_t *__pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + __Pyx_RefNannySetupContext("slice_copy", 0); + + /* "View.MemoryView":1050 + * cdef (Py_ssize_t*) shape, strides, suboffsets * + * shape = memview.view.shape # <<<<<<<<<<<<<< + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1313, __pyx_L1_error) + __pyx_t_1 = __pyx_v_memview->view.shape; + __pyx_v_shape = __pyx_t_1; - /* "View.MemoryView":1314 + /* "View.MemoryView":1051 * - * transpose_memslice(&src) - * transpose_memslice(&dst) # <<<<<<<<<<<<<< + * shape = memview.view.shape + * strides = memview.view.strides # <<<<<<<<<<<<<< + * suboffsets = memview.view.suboffsets * - * refcount_copying(&dst, dtype_is_object, ndim, False) */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1314, __pyx_L1_error) + __pyx_t_1 = __pyx_v_memview->view.strides; + __pyx_v_strides = __pyx_t_1; - /* "View.MemoryView":1310 - * return 0 - * - * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1052 + * shape = memview.view.shape + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< * + * dst.memview = <__pyx_memoryview *> memview */ - } + __pyx_t_1 = __pyx_v_memview->view.suboffsets; + __pyx_v_suboffsets = __pyx_t_1; - /* "View.MemoryView":1316 - * transpose_memslice(&dst) + /* "View.MemoryView":1054 + * suboffsets = memview.view.suboffsets + * + * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< + * dst.data = memview.view.buf * - * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * copy_strided_to_strided(&src, &dst, ndim, itemsize) - * refcount_copying(&dst, dtype_is_object, ndim, True) */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); - /* "View.MemoryView":1317 + /* "View.MemoryView":1055 * - * refcount_copying(&dst, dtype_is_object, ndim, False) - * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< - * refcount_copying(&dst, dtype_is_object, ndim, True) + * dst.memview = <__pyx_memoryview *> memview + * dst.data = memview.view.buf # <<<<<<<<<<<<<< * + * for dim in range(memview.view.ndim): */ - copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); + __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); - /* "View.MemoryView":1318 - * refcount_copying(&dst, dtype_is_object, ndim, False) - * copy_strided_to_strided(&src, &dst, ndim, itemsize) - * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + /* "View.MemoryView":1057 + * dst.data = memview.view.buf * - * free(tmpdata) + * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + __pyx_t_2 = __pyx_v_memview->view.ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_dim = __pyx_t_3; - /* "View.MemoryView":1320 - * refcount_copying(&dst, dtype_is_object, ndim, True) - * - * free(tmpdata) # <<<<<<<<<<<<<< - * return 0 + /* "View.MemoryView":1058 * + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 */ - free(__pyx_v_tmpdata); + (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); - /* "View.MemoryView":1321 - * - * free(tmpdata) - * return 0 # <<<<<<<<<<<<<< + /* "View.MemoryView":1059 + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 * - * @cname('__pyx_memoryview_broadcast_leading') */ - __pyx_r = 0; - goto __pyx_L0; + (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); - /* "View.MemoryView":1252 + /* "View.MemoryView":1060 + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_copy_contents') - * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice dst, - * int src_ndim, int dst_ndim, + * @cname('__pyx_memoryview_copy_object') + */ + if ((__pyx_v_suboffsets != 0)) { + __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]); + } else { + __pyx_t_4 = -1L; + } + (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4; + } + + /* "View.MemoryView":1046 + * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + */ + +static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) { + __Pyx_memviewslice __pyx_v_memviewslice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("memoryview_copy", 0); + + /* "View.MemoryView":1066 + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< + * return memoryview_copy_from_slice(memview, &memviewslice) + * + */ + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); + + /* "View.MemoryView":1067 + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) + * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_object_from_slice') + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1067, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice */ /* function exit code */ __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = -1; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":1324 +/* "View.MemoryView":1070 * - * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< - * int ndim, - * int ndim_other) nogil: + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. */ -static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { - int __pyx_v_i; - int __pyx_v_offset; +static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) { + PyObject *(*__pyx_v_to_object_func)(char *); + int (*__pyx_v_to_dtype_func)(char *, PyObject *); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; + PyObject *(*__pyx_t_3)(char *); + int (*__pyx_t_4)(char *, PyObject *); + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); - /* "View.MemoryView":1328 - * int ndim_other) nogil: - * cdef int i - * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< - * - * for i in range(ndim - 1, -1, -1): - */ - __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); - - /* "View.MemoryView":1330 - * cdef int offset = ndim_other - ndim + /* "View.MemoryView":1077 + * cdef int (*to_dtype_func)(char *, object) except 0 * - * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { - __pyx_v_i = __pyx_t_1; + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1331 + /* "View.MemoryView":1078 * - * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: */ - (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); + __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; + __pyx_v_to_object_func = __pyx_t_3; - /* "View.MemoryView":1332 - * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] - * + /* "View.MemoryView":1079 + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< + * else: + * to_object_func = NULL */ - (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); + __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func; + __pyx_v_to_dtype_func = __pyx_t_4; - /* "View.MemoryView":1333 - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< + /* "View.MemoryView":1077 + * cdef int (*to_dtype_func)(char *, object) except 0 * - * for i in range(offset): + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func */ - (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); + goto __pyx_L3; } - /* "View.MemoryView":1335 - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + /* "View.MemoryView":1081 + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: + * to_object_func = NULL # <<<<<<<<<<<<<< + * to_dtype_func = NULL * - * for i in range(offset): # <<<<<<<<<<<<<< - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] */ - __pyx_t_1 = __pyx_v_offset; - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_i = __pyx_t_2; + /*else*/ { + __pyx_v_to_object_func = NULL; - /* "View.MemoryView":1336 + /* "View.MemoryView":1082 + * else: + * to_object_func = NULL + * to_dtype_func = NULL # <<<<<<<<<<<<<< * - * for i in range(offset): - * mslice.shape[i] = 1 # <<<<<<<<<<<<<< - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, */ - (__pyx_v_mslice->shape[__pyx_v_i]) = 1; + __pyx_v_to_dtype_func = NULL; + } + __pyx_L3:; - /* "View.MemoryView":1337 - * for i in range(offset): - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< - * mslice.suboffsets[i] = -1 + /* "View.MemoryView":1084 + * to_dtype_func = NULL * + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< + * to_object_func, to_dtype_func, + * memview.dtype_is_object) */ - (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); + __Pyx_XDECREF(__pyx_r); - /* "View.MemoryView":1338 - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + /* "View.MemoryView":1086 + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + * to_object_func, to_dtype_func, + * memview.dtype_is_object) # <<<<<<<<<<<<<< * * */ - (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; - } + __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1084, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; - /* "View.MemoryView":1324 + /* "View.MemoryView":1070 * - * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< - * int ndim, - * int ndim_other) nogil: + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. */ /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; } -/* "View.MemoryView":1346 +/* "View.MemoryView":1092 * - * @cname('__pyx_memoryview_refcount_copying') - * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< - * int ndim, bint inc) nogil: * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg */ -static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { +static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { + Py_ssize_t __pyx_r; int __pyx_t_1; - /* "View.MemoryView":1350 - * + /* "View.MemoryView":1093 * - * if dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, - * dst.strides, ndim, inc) + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: */ - __pyx_t_1 = (__pyx_v_dtype_is_object != 0); + __pyx_t_1 = ((__pyx_v_arg < 0) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1351 - * - * if dtype_is_object: - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< - * dst.strides, ndim, inc) - * + /* "View.MemoryView":1094 + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: + * return -arg # <<<<<<<<<<<<<< + * else: + * return arg */ - __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc); + __pyx_r = (-__pyx_v_arg); + goto __pyx_L0; - /* "View.MemoryView":1350 + /* "View.MemoryView":1093 * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: + */ + } + + /* "View.MemoryView":1096 + * return -arg + * else: + * return arg # <<<<<<<<<<<<<< * - * if dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, - * dst.strides, ndim, inc) + * @cname('__pyx_get_best_slice_order') */ + /*else*/ { + __pyx_r = __pyx_v_arg; + goto __pyx_L0; } - /* "View.MemoryView":1346 + /* "View.MemoryView":1092 * - * @cname('__pyx_memoryview_refcount_copying') - * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< - * int ndim, bint inc) nogil: * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg */ /* function exit code */ + __pyx_L0:; + return __pyx_r; } -/* "View.MemoryView":1355 +/* "View.MemoryView":1099 * - * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') - * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. */ -static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { - __Pyx_RefNannyDeclarations - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); +static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) { + int __pyx_v_i; + Py_ssize_t __pyx_v_c_stride; + Py_ssize_t __pyx_v_f_stride; + char __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; - /* "View.MemoryView":1358 - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: - * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< + /* "View.MemoryView":1104 + * """ + * cdef int i + * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< + * cdef Py_ssize_t f_stride = 0 * - * @cname('__pyx_memoryview_refcount_objects_in_slice') */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); + __pyx_v_c_stride = 0; - /* "View.MemoryView":1355 + /* "View.MemoryView":1105 + * cdef int i + * cdef Py_ssize_t c_stride = 0 + * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< * - * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') - * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: + * for i in range(ndim - 1, -1, -1): */ + __pyx_v_f_stride = 0; - /* function exit code */ - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif -} - -/* "View.MemoryView":1361 + /* "View.MemoryView":1107 + * cdef Py_ssize_t f_stride = 0 * - * @cname('__pyx_memoryview_refcount_objects_in_slice') - * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, bint inc): - * cdef Py_ssize_t i + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; -static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { - CYTHON_UNUSED Py_ssize_t __pyx_v_i; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); - - /* "View.MemoryView":1365 - * cdef Py_ssize_t i + /* "View.MemoryView":1108 * - * for i in range(shape[0]): # <<<<<<<<<<<<<< - * if ndim == 1: - * if inc: + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break */ - __pyx_t_1 = (__pyx_v_shape[0]); - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_i = __pyx_t_2; + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1366 + /* "View.MemoryView":1109 + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break * - * for i in range(shape[0]): - * if ndim == 1: # <<<<<<<<<<<<<< - * if inc: - * Py_INCREF(( data)[0]) */ - __pyx_t_3 = ((__pyx_v_ndim == 1) != 0); - if (__pyx_t_3) { + __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - /* "View.MemoryView":1367 - * for i in range(shape[0]): - * if ndim == 1: - * if inc: # <<<<<<<<<<<<<< - * Py_INCREF(( data)[0]) - * else: + /* "View.MemoryView":1110 + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< + * + * for i in range(ndim): */ - __pyx_t_3 = (__pyx_v_inc != 0); - if (__pyx_t_3) { + goto __pyx_L4_break; - /* "View.MemoryView":1368 - * if ndim == 1: - * if inc: - * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< - * else: - * Py_DECREF(( data)[0]) + /* "View.MemoryView":1108 + * + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break */ - Py_INCREF((((PyObject **)__pyx_v_data)[0])); + } + } + __pyx_L4_break:; - /* "View.MemoryView":1367 - * for i in range(shape[0]): - * if ndim == 1: - * if inc: # <<<<<<<<<<<<<< - * Py_INCREF(( data)[0]) - * else: + /* "View.MemoryView":1112 + * break + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] */ - goto __pyx_L6; - } + __pyx_t_1 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1370 - * Py_INCREF(( data)[0]) - * else: - * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, + /* "View.MemoryView":1113 + * + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break */ - /*else*/ { - Py_DECREF((((PyObject **)__pyx_v_data)[0])); - } - __pyx_L6:; + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1366 + /* "View.MemoryView":1114 + * for i in range(ndim): + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break * - * for i in range(shape[0]): - * if ndim == 1: # <<<<<<<<<<<<<< - * if inc: - * Py_INCREF(( data)[0]) */ - goto __pyx_L5; - } + __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - /* "View.MemoryView":1372 - * Py_DECREF(( data)[0]) - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< - * ndim - 1, inc) + /* "View.MemoryView":1115 + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): */ - /*else*/ { + goto __pyx_L7_break; - /* "View.MemoryView":1373 - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, - * ndim - 1, inc) # <<<<<<<<<<<<<< + /* "View.MemoryView":1113 * - * data += strides[0] + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc); } - __pyx_L5:; + } + __pyx_L7_break:; - /* "View.MemoryView":1375 - * ndim - 1, inc) - * - * data += strides[0] # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1117 + * break * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: */ - __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); - } + __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1361 + /* "View.MemoryView":1118 * - * @cname('__pyx_memoryview_refcount_objects_in_slice') - * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, bint inc): - * cdef Py_ssize_t i + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + * return 'C' # <<<<<<<<<<<<<< + * else: + * return 'F' */ + __pyx_r = 'C'; + goto __pyx_L0; - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":1381 + /* "View.MemoryView":1117 + * break * - * @cname('__pyx_memoryview_slice_assign_scalar') - * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: - */ - -static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { - - /* "View.MemoryView":1384 - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: - * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, - * itemsize, item) - */ - __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - - /* "View.MemoryView":1385 - * bint dtype_is_object) nogil: - * refcount_copying(dst, dtype_is_object, ndim, False) - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< - * itemsize, item) - * refcount_copying(dst, dtype_is_object, ndim, True) + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: */ - __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); + } - /* "View.MemoryView":1387 - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, - * itemsize, item) - * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1120 + * return 'C' + * else: + * return 'F' # <<<<<<<<<<<<<< * + * @cython.cdivision(True) */ - __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + /*else*/ { + __pyx_r = 'F'; + goto __pyx_L0; + } - /* "View.MemoryView":1381 + /* "View.MemoryView":1099 * - * @cname('__pyx_memoryview_slice_assign_scalar') - * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. */ /* function exit code */ + __pyx_L0:; + return __pyx_r; } -/* "View.MemoryView":1391 +/* "View.MemoryView":1123 * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, */ -static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) { +static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) { CYTHON_UNUSED Py_ssize_t __pyx_v_i; - Py_ssize_t __pyx_v_stride; - Py_ssize_t __pyx_v_extent; + CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent; + Py_ssize_t __pyx_v_dst_extent; + Py_ssize_t __pyx_v_src_stride; + Py_ssize_t __pyx_v_dst_stride; int __pyx_t_1; - Py_ssize_t __pyx_t_2; - Py_ssize_t __pyx_t_3; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + Py_ssize_t __pyx_t_5; - /* "View.MemoryView":1395 - * size_t itemsize, void *item) nogil: - * cdef Py_ssize_t i - * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t extent = shape[0] + /* "View.MemoryView":1130 * + * cdef Py_ssize_t i + * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] */ - __pyx_v_stride = (__pyx_v_strides[0]); + __pyx_v_src_extent = (__pyx_v_src_shape[0]); - /* "View.MemoryView":1396 + /* "View.MemoryView":1131 * cdef Py_ssize_t i - * cdef Py_ssize_t stride = strides[0] - * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] + */ + __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); + + /* "View.MemoryView":1132 + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + */ + __pyx_v_src_stride = (__pyx_v_src_strides[0]); + + /* "View.MemoryView":1133 + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< * * if ndim == 1: */ - __pyx_v_extent = (__pyx_v_shape[0]); + __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); - /* "View.MemoryView":1398 - * cdef Py_ssize_t extent = shape[0] + /* "View.MemoryView":1135 + * cdef Py_ssize_t dst_stride = dst_strides[0] * * if ndim == 1: # <<<<<<<<<<<<<< - * for i in range(extent): - * memcpy(data, item, itemsize) + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): */ __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1399 + /* "View.MemoryView":1136 * * if ndim == 1: - * for i in range(extent): # <<<<<<<<<<<<<< - * memcpy(data, item, itemsize) - * data += stride + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) */ - __pyx_t_2 = __pyx_v_extent; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } - /* "View.MemoryView":1400 + /* "View.MemoryView":1137 * if ndim == 1: - * for i in range(extent): - * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< - * data += stride - * else: - */ - memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize); - - /* "View.MemoryView":1401 - * for i in range(extent): - * memcpy(data, item, itemsize) - * data += stride # <<<<<<<<<<<<<< - * else: - * for i in range(extent): + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: */ - __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize); + if (__pyx_t_2) { + __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride)); } + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L5_bool_binop_done:; - /* "View.MemoryView":1398 - * cdef Py_ssize_t extent = shape[0] + /* "View.MemoryView":1136 * - * if ndim == 1: # <<<<<<<<<<<<<< - * for i in range(extent): - * memcpy(data, item, itemsize) - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1403 - * data += stride - * else: - * for i in range(extent): # <<<<<<<<<<<<<< - * _slice_assign_scalar(data, shape + 1, strides + 1, - * ndim - 1, itemsize, item) + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) */ - /*else*/ { - __pyx_t_2 = __pyx_v_extent; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + if (__pyx_t_1) { - /* "View.MemoryView":1404 - * else: - * for i in range(extent): - * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< - * ndim - 1, itemsize, item) - * data += stride + /* "View.MemoryView":1138 + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): */ - __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); + memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)); - /* "View.MemoryView":1406 - * _slice_assign_scalar(data, shape + 1, strides + 1, - * ndim - 1, itemsize, item) - * data += stride # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1136 * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) */ - __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + goto __pyx_L4; } - } - __pyx_L3:; - /* "View.MemoryView":1391 - * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: + /* "View.MemoryView":1140 + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; - /* function exit code */ -} -static struct __pyx_vtabstruct_array __pyx_vtable_array; + /* "View.MemoryView":1141 + * else: + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< + * src_data += src_stride + * dst_data += dst_stride + */ + memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize); -static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_array_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_array_obj *)o); - p->__pyx_vtab = __pyx_vtabptr_array; - p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); - p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } - return o; -} + /* "View.MemoryView":1142 + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * else: + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); -static void __pyx_tp_dealloc_array(PyObject *o) { - struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_array___dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->mode); - Py_CLEAR(p->_format); - (*Py_TYPE(o)->tp_free)(o); -} -static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} + /* "View.MemoryView":1143 + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } + } + __pyx_L4:; -static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_array___setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); - return -1; + /* "View.MemoryView":1135 + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + */ + goto __pyx_L3; } -} -static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) { - PyObject *v = PyObject_GenericGetAttr(o, n); - if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - v = __pyx_array___getattr__(o, n); + /* "View.MemoryView":1145 + * dst_data += dst_stride + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * _copy_strided_to_strided(src_data, src_strides + 1, + * dst_data, dst_strides + 1, + */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":1146 + * else: + * for i in range(dst_extent): + * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< + * dst_data, dst_strides + 1, + * src_shape + 1, dst_shape + 1, + */ + _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); + + /* "View.MemoryView":1150 + * src_shape + 1, dst_shape + 1, + * ndim - 1, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + + /* "View.MemoryView":1151 + * ndim - 1, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } } - return v; -} + __pyx_L3:; -static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o); + /* "View.MemoryView":1123 + * + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + */ + + /* function exit code */ } -static PyMethodDef __pyx_methods_array[] = { - {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, - {0, 0, 0, 0} -}; +/* "View.MemoryView":1153 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ -static struct PyGetSetDef __pyx_getsets_array[] = { - {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; +static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { -static PySequenceMethods __pyx_tp_as_sequence_array = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_array, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; + /* "View.MemoryView":1156 + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< + * src.shape, dst.shape, ndim, itemsize) + * + */ + _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); -static PyMappingMethods __pyx_tp_as_mapping_array = { - 0, /*mp_length*/ - __pyx_array___getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/ -}; + /* "View.MemoryView":1153 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ -static PyBufferProcs __pyx_tp_as_buffer_array = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - __pyx_array_getbuffer, /*bf_getbuffer*/ - 0, /*bf_releasebuffer*/ -}; + /* function exit code */ +} -static PyTypeObject __pyx_type___pyx_array = { - PyVarObject_HEAD_INIT(0, 0) - "Orange.distance._distance.array", /*tp_name*/ - sizeof(struct __pyx_array_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_array, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_array, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_array, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - __pyx_tp_getattro_array, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_array, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_array, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_array, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_array, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; +/* "View.MemoryView":1160 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + */ -static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_MemviewEnum_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_MemviewEnum_obj *)o); - p->name = Py_None; Py_INCREF(Py_None); - return o; -} +static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) { + int __pyx_v_i; + Py_ssize_t __pyx_v_size; + Py_ssize_t __pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; -static void __pyx_tp_dealloc_Enum(PyObject *o) { - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->name); - (*Py_TYPE(o)->tp_free)(o); -} + /* "View.MemoryView":1163 + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + * cdef Py_ssize_t size = src.memview.view.itemsize # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_size = __pyx_t_1; -static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - if (p->name) { - e = (*v)(p->name, a); if (e) return e; - } - return 0; -} + /* "View.MemoryView":1165 + * cdef Py_ssize_t size = src.memview.view.itemsize + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * size *= src.shape[i] + * + */ + __pyx_t_2 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; -static int __pyx_tp_clear_Enum(PyObject *o) { - PyObject* tmp; - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - tmp = ((PyObject*)p->name); - p->name = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} + /* "View.MemoryView":1166 + * + * for i in range(ndim): + * size *= src.shape[i] # <<<<<<<<<<<<<< + * + * return size + */ + __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i])); + } -static PyMethodDef __pyx_methods_Enum[] = { - {0, 0, 0, 0} -}; + /* "View.MemoryView":1168 + * size *= src.shape[i] + * + * return size # <<<<<<<<<<<<<< + * + * @cname('__pyx_fill_contig_strides_array') + */ + __pyx_r = __pyx_v_size; + goto __pyx_L0; -static PyTypeObject __pyx_type___pyx_MemviewEnum = { - PyVarObject_HEAD_INIT(0, 0) - "Orange.distance._distance.Enum", /*tp_name*/ - sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_Enum, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - __pyx_MemviewEnum___repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_Enum, /*tp_traverse*/ - __pyx_tp_clear_Enum, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_Enum, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_MemviewEnum___init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_Enum, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview; + /* "View.MemoryView":1160 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef int i + */ -static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_memoryview_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_memoryview_obj *)o); - p->__pyx_vtab = __pyx_vtabptr_memoryview; - p->obj = Py_None; Py_INCREF(Py_None); - p->_size = Py_None; Py_INCREF(Py_None); - p->_array_interface = Py_None; Py_INCREF(Py_None); - p->view.obj = NULL; - if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } - return o; + /* function exit code */ + __pyx_L0:; + return __pyx_r; } -static void __pyx_tp_dealloc_memoryview(PyObject *o) { - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_memoryview___dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->obj); - Py_CLEAR(p->_size); - Py_CLEAR(p->_array_interface); - (*Py_TYPE(o)->tp_free)(o); -} +/* "View.MemoryView":1171 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ -static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - if (p->obj) { - e = (*v)(p->obj, a); if (e) return e; - } - if (p->_size) { - e = (*v)(p->_size, a); if (e) return e; - } - if (p->_array_interface) { - e = (*v)(p->_array_interface, a); if (e) return e; - } - if (p->view.obj) { - e = (*v)(p->view.obj, a); if (e) return e; - } - return 0; -} +static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) { + int __pyx_v_idx; + Py_ssize_t __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; -static int __pyx_tp_clear_memoryview(PyObject *o) { - PyObject* tmp; - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - tmp = ((PyObject*)p->obj); - p->obj = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_size); - p->_size = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_array_interface); - p->_array_interface = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - Py_CLEAR(p->view.obj); - return 0; -} -static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} + /* "View.MemoryView":1180 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + __pyx_t_1 = ((__pyx_v_order == 'F') != 0); + if (__pyx_t_1) { -static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_memoryview___setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); - return -1; - } -} + /* "View.MemoryView":1181 + * + * if order == 'F': + * for idx in range(ndim): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride = stride * shape[idx] + */ + __pyx_t_2 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_idx = __pyx_t_3; -static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o); -} + /* "View.MemoryView":1182 + * if order == 'F': + * for idx in range(ndim): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride = stride * shape[idx] + * else: + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; -static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o); -} + /* "View.MemoryView":1183 + * for idx in range(ndim): + * strides[idx] = stride + * stride = stride * shape[idx] # <<<<<<<<<<<<<< + * else: + * for idx in range(ndim - 1, -1, -1): + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } -static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o); -} + /* "View.MemoryView":1180 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + goto __pyx_L3; + } -static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o); -} + /* "View.MemoryView":1185 + * stride = stride * shape[idx] + * else: + * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride = stride * shape[idx] + */ + /*else*/ { + for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) { + __pyx_v_idx = __pyx_t_2; -static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o); -} + /* "View.MemoryView":1186 + * else: + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride = stride * shape[idx] + * + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; -static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o); -} + /* "View.MemoryView":1187 + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride + * stride = stride * shape[idx] # <<<<<<<<<<<<<< + * + * return stride + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } + } + __pyx_L3:; -static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o); -} + /* "View.MemoryView":1189 + * stride = stride * shape[idx] + * + * return stride # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_data_to_temp') + */ + __pyx_r = __pyx_v_stride; + goto __pyx_L0; -static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o); -} + /* "View.MemoryView":1171 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ -static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o); + /* function exit code */ + __pyx_L0:; + return __pyx_r; } -static PyMethodDef __pyx_methods_memoryview[] = { - {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0}, - {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, - {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, - {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, - {0, 0, 0, 0} -}; +/* "View.MemoryView":1192 + * + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, + */ -static struct PyGetSetDef __pyx_getsets_memoryview[] = { - {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0}, - {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0}, - {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0}, - {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0}, - {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0}, - {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0}, - {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0}, - {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0}, - {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; +static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) { + int __pyx_v_i; + void *__pyx_v_result; + size_t __pyx_v_itemsize; + size_t __pyx_v_size; + void *__pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + struct __pyx_memoryview_obj *__pyx_t_4; + int __pyx_t_5; -static PySequenceMethods __pyx_tp_as_sequence_memoryview = { - __pyx_memoryview___len__, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_memoryview, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; + /* "View.MemoryView":1203 + * cdef void *result + * + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef size_t size = slice_get_size(src, ndim) + * + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; -static PyMappingMethods __pyx_tp_as_mapping_memoryview = { - __pyx_memoryview___len__, /*mp_length*/ - __pyx_memoryview___getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/ -}; + /* "View.MemoryView":1204 + * + * cdef size_t itemsize = src.memview.view.itemsize + * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< + * + * result = malloc(size) + */ + __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); -static PyBufferProcs __pyx_tp_as_buffer_memoryview = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - __pyx_memoryview_getbuffer, /*bf_getbuffer*/ - 0, /*bf_releasebuffer*/ -}; + /* "View.MemoryView":1206 + * cdef size_t size = slice_get_size(src, ndim) + * + * result = malloc(size) # <<<<<<<<<<<<<< + * if not result: + * _err(MemoryError, NULL) + */ + __pyx_v_result = malloc(__pyx_v_size); -static PyTypeObject __pyx_type___pyx_memoryview = { - PyVarObject_HEAD_INIT(0, 0) - "Orange.distance._distance.memoryview", /*tp_name*/ - sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_memoryview, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - __pyx_memoryview___repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - __pyx_memoryview___str__, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_memoryview, /*tp_traverse*/ - __pyx_tp_clear_memoryview, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_memoryview, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_memoryview, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_memoryview, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice; + /* "View.MemoryView":1207 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ + __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); + if (__pyx_t_2) { -static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_memoryviewslice_obj *p; - PyObject *o = __pyx_tp_new_memoryview(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_memoryviewslice_obj *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice; - p->from_object = Py_None; Py_INCREF(Py_None); - p->from_slice.memview = NULL; - return o; -} + /* "View.MemoryView":1208 + * result = malloc(size) + * if not result: + * _err(MemoryError, NULL) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(2, 1208, __pyx_L1_error) -static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_memoryviewslice___dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); + /* "View.MemoryView":1207 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ } - Py_CLEAR(p->from_object); - PyObject_GC_Track(o); - __pyx_tp_dealloc_memoryview(o); -} -static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e; - if (p->from_object) { - e = (*v)(p->from_object, a); if (e) return e; - } - return 0; -} + /* "View.MemoryView":1211 + * + * + * tmpslice.data = result # <<<<<<<<<<<<<< + * tmpslice.memview = src.memview + * for i in range(ndim): + */ + __pyx_v_tmpslice->data = ((char *)__pyx_v_result); -static int __pyx_tp_clear__memoryviewslice(PyObject *o) { - PyObject* tmp; - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - __pyx_tp_clear_memoryview(o); - tmp = ((PyObject*)p->from_object); - p->from_object = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - __PYX_XDEC_MEMVIEW(&p->from_slice, 1); - return 0; -} + /* "View.MemoryView":1212 + * + * tmpslice.data = result + * tmpslice.memview = src.memview # <<<<<<<<<<<<<< + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + */ + __pyx_t_4 = __pyx_v_src->memview; + __pyx_v_tmpslice->memview = __pyx_t_4; -static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o); -} + /* "View.MemoryView":1213 + * tmpslice.data = result + * tmpslice.memview = src.memview + * for i in range(ndim): # <<<<<<<<<<<<<< + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 + */ + __pyx_t_3 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; -static PyMethodDef __pyx_methods__memoryviewslice[] = { - {0, 0, 0, 0} -}; + /* "View.MemoryView":1214 + * tmpslice.memview = src.memview + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< + * tmpslice.suboffsets[i] = -1 + * + */ + (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); -static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = { - {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; + /* "View.MemoryView":1215 + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, + */ + (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; + } -static PyTypeObject __pyx_type___pyx_memoryviewslice = { - PyVarObject_HEAD_INIT(0, 0) - "Orange.distance._distance._memoryviewslice", /*tp_name*/ - sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - #if CYTHON_COMPILING_IN_PYPY - __pyx_memoryview___repr__, /*tp_repr*/ - #else - 0, /*tp_repr*/ - #endif - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - #if CYTHON_COMPILING_IN_PYPY - __pyx_memoryview___str__, /*tp_str*/ - #else - 0, /*tp_str*/ - #endif - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - "Internal class for passing memoryview slices to Python", /*tp_doc*/ - __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/ - __pyx_tp_clear__memoryviewslice, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods__memoryviewslice, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets__memoryviewslice, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new__memoryviewslice, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; + /* "View.MemoryView":1217 + * tmpslice.suboffsets[i] = -1 + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< + * ndim, order) + * + */ + __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order); -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else - PyModuleDef_HEAD_INIT, - #endif - "_distance", - 0, /* m_doc */ - -1, /* m_size */ - __pyx_methods /* m_methods */, - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1}, - {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0}, - {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0}, - {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1}, - {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, - {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, - {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, - {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, - {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, - {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, - {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0}, - {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, - {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0}, - {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0}, - {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, - {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, - {&__pyx_n_s_Orange_distance__distance, __pyx_k_Orange_distance__distance, sizeof(__pyx_k_Orange_distance__distance), 0, 0, 1, 1}, - {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, - {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_n_s_abs1, __pyx_k_abs1, sizeof(__pyx_k_abs1), 0, 0, 1, 1}, - {&__pyx_n_s_abs2, __pyx_k_abs2, sizeof(__pyx_k_abs2), 0, 0, 1, 1}, - {&__pyx_n_s_abss, __pyx_k_abss, sizeof(__pyx_k_abss), 0, 0, 1, 1}, - {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, - {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, - {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, - {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, - {&__pyx_kp_s_cannot_normalize_the_data_has_no, __pyx_k_cannot_normalize_the_data_has_no, sizeof(__pyx_k_cannot_normalize_the_data_has_no), 0, 0, 1, 0}, - {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, - {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, - {&__pyx_n_s_col1, __pyx_k_col1, sizeof(__pyx_k_col1), 0, 0, 1, 1}, - {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, - {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, - {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_cosine_cols, __pyx_k_cosine_cols, sizeof(__pyx_k_cosine_cols), 0, 0, 1, 1}, - {&__pyx_n_s_cosine_rows, __pyx_k_cosine_rows, sizeof(__pyx_k_cosine_rows), 0, 0, 1, 1}, - {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, - {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, - {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, - {&__pyx_n_s_distances, __pyx_k_distances, sizeof(__pyx_k_distances), 0, 0, 1, 1}, - {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, - {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, - {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, - {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, - {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, - {&__pyx_n_s_euclidean_cols, __pyx_k_euclidean_cols, sizeof(__pyx_k_euclidean_cols), 0, 0, 1, 1}, - {&__pyx_n_s_euclidean_rows, __pyx_k_euclidean_rows, sizeof(__pyx_k_euclidean_rows), 0, 0, 1, 1}, - {&__pyx_n_s_fit_params, __pyx_k_fit_params, sizeof(__pyx_k_fit_params), 0, 0, 1, 1}, - {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, - {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, - {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, - {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, - {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, - {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_in1_unk2, __pyx_k_in1_unk2, sizeof(__pyx_k_in1_unk2), 0, 0, 1, 1}, - {&__pyx_n_s_in_both, __pyx_k_in_both, sizeof(__pyx_k_in_both), 0, 0, 1, 1}, - {&__pyx_n_s_in_one, __pyx_k_in_one, sizeof(__pyx_k_in_one), 0, 0, 1, 1}, - {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, - {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1}, - {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, - {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, - {&__pyx_n_s_ival1, __pyx_k_ival1, sizeof(__pyx_k_ival1), 0, 0, 1, 1}, - {&__pyx_n_s_ival2, __pyx_k_ival2, sizeof(__pyx_k_ival2), 0, 0, 1, 1}, - {&__pyx_n_s_jaccard_cols, __pyx_k_jaccard_cols, sizeof(__pyx_k_jaccard_cols), 0, 0, 1, 1}, - {&__pyx_n_s_jaccard_rows, __pyx_k_jaccard_rows, sizeof(__pyx_k_jaccard_rows), 0, 0, 1, 1}, - {&__pyx_n_s_mads, __pyx_k_mads, sizeof(__pyx_k_mads), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_manhattan_cols, __pyx_k_manhattan_cols, sizeof(__pyx_k_manhattan_cols), 0, 0, 1, 1}, - {&__pyx_n_s_manhattan_rows, __pyx_k_manhattan_rows, sizeof(__pyx_k_manhattan_rows), 0, 0, 1, 1}, - {&__pyx_n_s_means, __pyx_k_means, sizeof(__pyx_k_means), 0, 0, 1, 1}, - {&__pyx_n_s_medians, __pyx_k_medians, sizeof(__pyx_k_medians), 0, 0, 1, 1}, - {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, - {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, - {&__pyx_n_s_n_cols, __pyx_k_n_cols, sizeof(__pyx_k_n_cols), 0, 0, 1, 1}, - {&__pyx_n_s_n_rows, __pyx_k_n_rows, sizeof(__pyx_k_n_rows), 0, 0, 1, 1}, - {&__pyx_n_s_n_rows1, __pyx_k_n_rows1, sizeof(__pyx_k_n_rows1), 0, 0, 1, 1}, - {&__pyx_n_s_n_rows2, __pyx_k_n_rows2, sizeof(__pyx_k_n_rows2), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, - {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, - {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, - {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, - {&__pyx_n_s_nonnans, __pyx_k_nonnans, sizeof(__pyx_k_nonnans), 0, 0, 1, 1}, - {&__pyx_n_s_nonzeros, __pyx_k_nonzeros, sizeof(__pyx_k_nonzeros), 0, 0, 1, 1}, - {&__pyx_n_s_normalize, __pyx_k_normalize, sizeof(__pyx_k_normalize), 0, 0, 1, 1}, - {&__pyx_n_s_not1_unk2, __pyx_k_not1_unk2, sizeof(__pyx_k_not1_unk2), 0, 0, 1, 1}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, - {&__pyx_n_s_p_nonzero, __pyx_k_p_nonzero, sizeof(__pyx_k_p_nonzero), 0, 0, 1, 1}, - {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, - {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 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_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, - {&__pyx_n_s_row1, __pyx_k_row1, sizeof(__pyx_k_row1), 0, 0, 1, 1}, - {&__pyx_n_s_row2, __pyx_k_row2, sizeof(__pyx_k_row2), 0, 0, 1, 1}, - {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, - {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, - {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, - {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, - {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1}, - {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, - {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, - {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, - {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_two_tables, __pyx_k_two_tables, sizeof(__pyx_k_two_tables), 0, 0, 1, 1}, - {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, - {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, - {&__pyx_n_s_union, __pyx_k_union, sizeof(__pyx_k_union), 0, 0, 1, 1}, - {&__pyx_n_s_unk1_in2, __pyx_k_unk1_in2, sizeof(__pyx_k_unk1_in2), 0, 0, 1, 1}, - {&__pyx_n_s_unk1_not2, __pyx_k_unk1_not2, sizeof(__pyx_k_unk1_not2), 0, 0, 1, 1}, - {&__pyx_n_s_unk1_unk2, __pyx_k_unk1_unk2, sizeof(__pyx_k_unk1_unk2), 0, 0, 1, 1}, - {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, - {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1}, - {&__pyx_n_s_val1, __pyx_k_val1, sizeof(__pyx_k_val1), 0, 0, 1, 1}, - {&__pyx_n_s_val2, __pyx_k_val2, sizeof(__pyx_k_val2), 0, 0, 1, 1}, - {&__pyx_n_s_vars, __pyx_k_vars, sizeof(__pyx_k_vars), 0, 0, 1, 1}, - {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, - {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1}, - {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1}, - {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 21, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 23, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) - __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 396, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 425, __pyx_L1_error) - __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 599, __pyx_L1_error) - __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 818, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "Orange/distance/_distance.pyx":23 - * for col in range(dividers.shape[0]): - * if dividers[col] == 0 and not x[:, col].isnan().all(): - * raise ValueError("cannot normalize: the data has no variance") # <<<<<<<<<<<<<< + /* "View.MemoryView":1221 * * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_normalize_the_data_has_no); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); + __pyx_t_3 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; - /* "Orange/distance/_distance.pyx":390 - * for col1 in range(n_cols): - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< - * continue - * with nogil: + /* "View.MemoryView":1222 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 + * */ - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 390, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__3); - __Pyx_GIVEREF(__pyx_slice__3); + __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + /* "View.MemoryView":1223 + * for i in range(ndim): + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * if slice_is_contig(src[0], order, ndim): */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + /* "View.MemoryView":1222 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 * - * info.buf = PyArray_DATA(self) */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); + } + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 - * if ((descr.byteorder == c'>' and little_endian) or - * (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" + /* "View.MemoryView":1225 + * tmpslice.strides[i] = 0 + * + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0); + if (__pyx_t_2) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "View.MemoryView":1226 * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * if slice_is_contig(src[0], order, ndim): + * memcpy(result, src.data, size) # <<<<<<<<<<<<<< + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) + */ + memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size); + + /* "View.MemoryView":1225 + * tmpslice.strides[i] = 0 * - * if ((child.byteorder == c'>' and little_endian) or + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + goto __pyx_L9; + } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + /* "View.MemoryView":1228 + * memcpy(result, src.data, size) + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< * - * # Until ticket #99 is fixed, use integers to avoid warnings + * return result */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); + /*else*/ { + copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize); + } + __pyx_L9:; - /* "View.MemoryView":131 - * - * if not self.ndim: - * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + /* "View.MemoryView":1230 + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) * - * if itemsize <= 0: - */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - - /* "View.MemoryView":134 + * return result # <<<<<<<<<<<<<< * - * if itemsize <= 0: - * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< * - * if not isinstance(format, bytes): */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_r = __pyx_v_result; + goto __pyx_L0; - /* "View.MemoryView":137 + /* "View.MemoryView":1192 * - * if not isinstance(format, bytes): - * format = format.encode('ASCII') # <<<<<<<<<<<<<< - * self._format = format # keep a reference to the byte string - * self.format = self._format + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); - /* "View.MemoryView":146 - * - * if not self._shape: - * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = NULL; + __pyx_L0:; + return __pyx_r; +} - /* "View.MemoryView":174 - * self.data = malloc(self.len) - * if not self.data: - * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< +/* "View.MemoryView":1235 * - * if self.dtype_is_object: - */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); - - /* "View.MemoryView":190 - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< - * info.buf = self.data - * info.len = self.len + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % */ - __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - /* "View.MemoryView":484 - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< - * else: - * if len(self.view.format) == 1: - */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 484, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); +static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_extents", 0); - /* "View.MemoryView":556 - * if self.view.strides == NULL: - * - * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + /* "View.MemoryView":1238 + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + * (i, extent1, extent2)) # <<<<<<<<<<<<<< * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + * @cname('__pyx_memoryview_err_dim') */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 556, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; - /* "View.MemoryView":563 - * def suboffsets(self): - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + /* "View.MemoryView":1237 + * cdef int _err_extents(int i, Py_ssize_t extent1, + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< + * (i, extent1, extent2)) * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) - */ - __pyx_tuple__18 = PyTuple_New(1); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_INCREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__18, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__18); - - /* "View.MemoryView":668 - * if item is Ellipsis: - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< - * seen_ellipsis = True - * else: - */ - __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__19); - __Pyx_GIVEREF(__pyx_slice__19); - - /* "View.MemoryView":671 - * seen_ellipsis = True - * else: - * result.append(slice(None)) # <<<<<<<<<<<<<< - * have_slices = True - * else: */ - __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(2, 671, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__20); - __Pyx_GIVEREF(__pyx_slice__20); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 1237, __pyx_L1_error) - /* "View.MemoryView":682 - * nslices = ndim - len(result) - * if nslices: - * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + /* "View.MemoryView":1235 * - * return have_slices or nslices, tuple(result) + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % */ - __pyx_slice__21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__21); - __Pyx_GIVEREF(__pyx_slice__21); - /* "View.MemoryView":689 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":33 +/* "View.MemoryView":1241 * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) * - * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, */ - __pyx_tuple__23 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 33, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":93 - * - * - * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] means = fit_params["means"] - */ - __pyx_tuple__25 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_cols, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 93, __pyx_L1_error) +static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_dim", 0); + __Pyx_INCREF(__pyx_v_error); - /* "Orange/distance/_distance.pyx":138 - * - * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, - */ - __pyx_tuple__27 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 138, __pyx_L1_error) - - /* "Orange/distance/_distance.pyx":201 - * + /* "View.MemoryView":1242 + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: + * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * @cname('__pyx_memoryview_err') */ - __pyx_tuple__29 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 201, __pyx_L1_error) + __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_v_error); + __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_2) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1242, __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 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 1242, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":246 + /* "View.MemoryView":1241 * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans */ - __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 246, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":290 - * - * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, - */ - __pyx_tuple__33 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 290, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__33); - __Pyx_GIVEREF(__pyx_tuple__33); - __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 290, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 290, __pyx_L1_error) + /* 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_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":372 - * +/* "View.MemoryView":1245 * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] vars = fit_params["vars"] + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) */ - __pyx_tuple__35 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 372, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__35); - __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 372, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 372, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":417 - * - * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, - */ - __pyx_tuple__37 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 417, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__37); - __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 417, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 417, __pyx_L1_error) +static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err", 0); + __Pyx_INCREF(__pyx_v_error); - /* "Orange/distance/_distance.pyx":468 - * - * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + /* "View.MemoryView":1246 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: */ - __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 468, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__39); - __Pyx_GIVEREF(__pyx_tuple__39); - __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 468, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); + if (__pyx_t_1) { - /* "View.MemoryView":282 - * return self.name - * - * cdef generic = Enum("") # <<<<<<<<<<<<<< - * cdef strided = Enum("") # default - * cdef indirect = Enum("") + /* "View.MemoryView":1247 + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: + * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< + * else: + * raise error */ - __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__41); - __Pyx_GIVEREF(__pyx_tuple__41); + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_error); + __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(2, 1247, __pyx_L1_error) - /* "View.MemoryView":283 - * - * cdef generic = Enum("") - * cdef strided = Enum("") # default # <<<<<<<<<<<<<< - * cdef indirect = Enum("") - * + /* "View.MemoryView":1246 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: */ - __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(2, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__42); - __Pyx_GIVEREF(__pyx_tuple__42); + } - /* "View.MemoryView":284 - * cdef generic = Enum("") - * cdef strided = Enum("") # default - * cdef indirect = Enum("") # <<<<<<<<<<<<<< - * + /* "View.MemoryView":1249 + * raise error(msg.decode('ascii')) + * else: + * raise error # <<<<<<<<<<<<<< * + * @cname('__pyx_memoryview_copy_contents') */ - __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(2, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__43); - __Pyx_GIVEREF(__pyx_tuple__43); + /*else*/ { + __Pyx_Raise(__pyx_v_error, 0, 0, 0); + __PYX_ERR(2, 1249, __pyx_L1_error) + } - /* "View.MemoryView":287 - * - * - * cdef contiguous = Enum("") # <<<<<<<<<<<<<< - * cdef indirect_contiguous = Enum("") + /* "View.MemoryView":1245 * + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) */ - __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(2, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__44); - __Pyx_GIVEREF(__pyx_tuple__44); - /* "View.MemoryView":288 - * - * cdef contiguous = Enum("") - * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(2, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__45); - __Pyx_GIVEREF(__pyx_tuple__45); - __Pyx_RefNannyFinishContext(); - return 0; + /* function exit code */ __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); __Pyx_RefNannyFinishContext(); - return -1; + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; } -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} +/* "View.MemoryView":1252 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_distance(void); /*proto*/ -PyMODINIT_FUNC init_distance(void) -#else -PyMODINIT_FUNC PyInit__distance(void); /*proto*/ -PyMODINIT_FUNC PyInit__distance(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; - static PyThread_type_lock __pyx_t_2[8]; - __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__distance(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_distance", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_Orange__distance___distance) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "Orange.distance._distance")) { - if (unlikely(PyDict_SetItemString(modules, "Orange.distance._distance", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - generic = Py_None; Py_INCREF(Py_None); - strided = Py_None; Py_INCREF(Py_None); - indirect = Py_None; Py_INCREF(Py_None); - contiguous = Py_None; Py_INCREF(Py_None); - indirect_contiguous = Py_None; Py_INCREF(Py_None); - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_array = &__pyx_vtable_array; - __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; - if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) - __pyx_type___pyx_array.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) - __pyx_array_type = &__pyx_type___pyx_array; - if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 275, __pyx_L1_error) - __pyx_type___pyx_MemviewEnum.tp_print = 0; - __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; - __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; - __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; - __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice; - __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment; - __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar; - __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed; - __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object; - __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object; - if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) - __pyx_type___pyx_memoryview.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) - __pyx_memoryview_type = &__pyx_type___pyx_memoryview; - __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; - __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; - __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; - __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; - __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; - if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) - __pyx_type___pyx_memoryviewslice.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) - __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if CYTHON_COMPILING_IN_PYPY - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif +static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) { + void *__pyx_v_tmpdata; + size_t __pyx_v_itemsize; + int __pyx_v_i; + char __pyx_v_order; + int __pyx_v_broadcasting; + int __pyx_v_direct_copy; + __Pyx_memviewslice __pyx_v_tmp; + int __pyx_v_ndim; + int __pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + void *__pyx_t_6; + int __pyx_t_7; - /* "Orange/distance/_distance.pyx":7 - * #cython: wraparound=False - * - * import numpy as np # <<<<<<<<<<<<<< - * cimport numpy as np - * + /* "View.MemoryView":1260 + * Check for overlapping memory and verify the shapes. + * """ + * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_tmpdata = NULL; - /* "Orange/distance/_distance.pyx":33 - * - * - * def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "View.MemoryView":1261 + * """ + * cdef void *tmpdata = NULL + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __pyx_v_src.memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; - /* "Orange/distance/_distance.pyx":93 - * - * - * def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] means = fit_params["means"] + /* "View.MemoryView":1263 + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< + * cdef bint broadcasting = False + * cdef bint direct_copy = False */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); - /* "Orange/distance/_distance.pyx":138 - * - * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "View.MemoryView":1264 + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False # <<<<<<<<<<<<<< + * cdef bint direct_copy = False + * cdef __Pyx_memviewslice tmp */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_broadcasting = 0; - /* "Orange/distance/_distance.pyx":201 - * + /* "View.MemoryView":1265 + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False + * cdef bint direct_copy = False # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice tmp * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_direct_copy = 0; - /* "Orange/distance/_distance.pyx":246 - * + /* "View.MemoryView":1268 + * cdef __Pyx_memviewslice tmp * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); + if (__pyx_t_2) { - /* "Orange/distance/_distance.pyx":290 - * + /* "View.MemoryView":1269 * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 290, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim); - /* "Orange/distance/_distance.pyx":372 - * + /* "View.MemoryView":1268 + * cdef __Pyx_memviewslice tmp * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] vars = fit_params["vars"] + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 372, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L3; + } - /* "Orange/distance/_distance.pyx":417 - * + /* "View.MemoryView":1270 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 417, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); + if (__pyx_t_2) { - /* "Orange/distance/_distance.pyx":468 - * + /* "View.MemoryView":1271 + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + * cdef int ndim = max(src_ndim, dst_ndim) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 468, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim); - /* "Orange/distance/_distance.pyx":1 - * #cython: embedsignature=True # <<<<<<<<<<<<<< - * #cython: infer_types=True - * #cython: cdivision=True + /* "View.MemoryView":1270 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) + * */ - __pyx_t_1 = PyDict_New(); 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; + } + __pyx_L3:; - /* "View.MemoryView":207 - * info.obj = self + /* "View.MemoryView":1273 + * broadcast_leading(&dst, dst_ndim, src_ndim) * - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< * - * def __dealloc__(array self): + * for i in range(ndim): */ - __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 207, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_array_type); + __pyx_t_3 = __pyx_v_dst_ndim; + __pyx_t_4 = __pyx_v_src_ndim; + if (((__pyx_t_3 > __pyx_t_4) != 0)) { + __pyx_t_5 = __pyx_t_3; + } else { + __pyx_t_5 = __pyx_t_4; + } + __pyx_v_ndim = __pyx_t_5; - /* "View.MemoryView":282 - * return self.name + /* "View.MemoryView":1275 + * cdef int ndim = max(src_ndim, dst_ndim) * - * cdef generic = Enum("") # <<<<<<<<<<<<<< - * cdef strided = Enum("") # default - * cdef indirect = Enum("") + * for i in range(ndim): # <<<<<<<<<<<<<< + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(generic); - __Pyx_DECREF_SET(generic, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":283 - * - * cdef generic = Enum("") - * cdef strided = Enum("") # default # <<<<<<<<<<<<<< - * cdef indirect = Enum("") + /* "View.MemoryView":1276 * + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(strided); - __Pyx_DECREF_SET(strided, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":284 - * cdef generic = Enum("") - * cdef strided = Enum("") # default - * cdef indirect = Enum("") # <<<<<<<<<<<<<< - * - * + /* "View.MemoryView":1277 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(indirect); - __Pyx_DECREF_SET(indirect, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":287 - * - * - * cdef contiguous = Enum("") # <<<<<<<<<<<<<< - * cdef indirect_contiguous = Enum("") + /* "View.MemoryView":1278 + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: + * broadcasting = True # <<<<<<<<<<<<<< + * src.strides[i] = 0 + * else: + */ + __pyx_v_broadcasting = 1; + + /* "View.MemoryView":1279 + * if src.shape[i] == 1: + * broadcasting = True + * src.strides[i] = 0 # <<<<<<<<<<<<<< + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) + */ + (__pyx_v_src.strides[__pyx_v_i]) = 0; + + /* "View.MemoryView":1277 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 + */ + goto __pyx_L7; + } + + /* "View.MemoryView":1281 + * src.strides[i] = 0 + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< * + * if src.suboffsets[i] >= 0: */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(contiguous); - __Pyx_DECREF_SET(contiguous, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + /*else*/ { + __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1281, __pyx_L1_error) + } + __pyx_L7:; - /* "View.MemoryView":288 + /* "View.MemoryView":1276 * - * cdef contiguous = Enum("") - * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True + */ + } + + /* "View.MemoryView":1283 + * _err_extents(i, dst.shape[i], src.shape[i]) * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(indirect_contiguous); - __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":312 + /* "View.MemoryView":1284 * - * DEF THREAD_LOCKS_PREALLOCATED = 8 - * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<< - * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ - * PyThread_allocate_lock(), + * if src.suboffsets[i] >= 0: + * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< + * + * if slices_overlap(&src, &dst, ndim, itemsize): */ - __pyx_memoryview_thread_locks_used = 0; + __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 1284, __pyx_L1_error) - /* "View.MemoryView":313 - * DEF THREAD_LOCKS_PREALLOCATED = 8 - * cdef int __pyx_memoryview_thread_locks_used = 0 - * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<< - * PyThread_allocate_lock(), - * PyThread_allocate_lock(), + /* "View.MemoryView":1283 + * _err_extents(i, dst.shape[i], src.shape[i]) + * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) + * */ - __pyx_t_2[0] = PyThread_allocate_lock(); - __pyx_t_2[1] = PyThread_allocate_lock(); - __pyx_t_2[2] = PyThread_allocate_lock(); - __pyx_t_2[3] = PyThread_allocate_lock(); - __pyx_t_2[4] = PyThread_allocate_lock(); - __pyx_t_2[5] = PyThread_allocate_lock(); - __pyx_t_2[6] = PyThread_allocate_lock(); - __pyx_t_2[7] = PyThread_allocate_lock(); - memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); + } + } - /* "View.MemoryView":535 - * info.obj = self - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + /* "View.MemoryView":1286 + * _err_dim(ValueError, "Dimension %d is not direct", i) * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< * + * if not slice_is_contig(src, order, ndim): */ - __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 535, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 535, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_memoryview_type); + __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":981 - * return self.from_object - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + /* "View.MemoryView":1288 + * if slices_overlap(&src, &dst, ndim, itemsize): * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) * */ - __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 981, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 981, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_memoryviewslice_type); + __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0); + if (__pyx_t_2) { - /* "View.MemoryView":1391 + /* "View.MemoryView":1289 * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: + * if not slice_is_contig(src, order, ndim): + * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) */ + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim); - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init Orange.distance._distance", __pyx_clineno, __pyx_lineno, __pyx_filename); + /* "View.MemoryView":1288 + * if slices_overlap(&src, &dst, ndim, itemsize): + * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) + * + */ } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init Orange.distance._distance"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else - return __pyx_m; - #endif -} -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif + /* "View.MemoryView":1291 + * order = get_best_order(&dst, ndim) + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< + * src = tmp + * + */ + __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(2, 1291, __pyx_L1_error) + __pyx_v_tmpdata = __pyx_t_6; -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} + /* "View.MemoryView":1292 + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + * src = tmp # <<<<<<<<<<<<<< + * + * if not broadcasting: + */ + __pyx_v_src = __pyx_v_tmp; -/* BufferFormatCheck */ -static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { - unsigned int n = 1; - return *(unsigned char*)(&n) != 0; -} -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t < '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; + /* "View.MemoryView":1286 + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + * + * if not slice_is_contig(src, order, ndim): + */ } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; + + /* "View.MemoryView":1294 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1297 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1298 + * + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<< + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim); + + /* "View.MemoryView":1297 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + goto __pyx_L12; } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; + + /* "View.MemoryView":1299 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1300 + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<< + * + * if direct_copy: + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim); + + /* "View.MemoryView":1299 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; + __pyx_L12:; + + /* "View.MemoryView":1302 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_2 = (__pyx_v_direct_copy != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1304 + * if direct_copy: + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1305 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + */ + memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)); + + /* "View.MemoryView":1306 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * free(tmpdata) + * return 0 + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1307 + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1308 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * if order == 'F' == get_best_order(&dst, ndim): + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1302 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ } + + /* "View.MemoryView":1294 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. + + /* "View.MemoryView":1310 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } + __pyx_t_2 = (__pyx_v_order == 'F'); + if (__pyx_t_2) { + __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim)); + } + __pyx_t_7 = (__pyx_t_2 != 0); + if (__pyx_t_7) { + + /* "View.MemoryView":1313 + * + * + * transpose_memslice(&src) # <<<<<<<<<<<<<< + * transpose_memslice(&dst) + * + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1313, __pyx_L1_error) + + /* "View.MemoryView":1314 + * + * transpose_memslice(&src) + * transpose_memslice(&dst) # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(2, 1314, __pyx_L1_error) + + /* "View.MemoryView":1310 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":1316 + * transpose_memslice(&dst) + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1317 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + */ + copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); + + /* "View.MemoryView":1318 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * free(tmpdata) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1320 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1321 + * + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_broadcast_leading') + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1252 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; } -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; + +/* "View.MemoryView":1324 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { + int __pyx_v_i; + int __pyx_v_offset; + int __pyx_t_1; + int __pyx_t_2; + + /* "View.MemoryView":1328 + * int ndim_other) nogil: + * cdef int i + * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< + * + * for i in range(ndim - 1, -1, -1): + */ + __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); + + /* "View.MemoryView":1330 + * cdef int offset = ndim_other - ndim + * + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":1331 + * + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + */ + (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); + + /* "View.MemoryView":1332 + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + */ + (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1333 + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< + * + * for i in range(offset): + */ + (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); + } + + /* "View.MemoryView":1335 + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + * for i in range(offset): # <<<<<<<<<<<<<< + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + */ + __pyx_t_1 = __pyx_v_offset; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "View.MemoryView":1336 + * + * for i in range(offset): + * mslice.shape[i] = 1 # <<<<<<<<<<<<<< + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 + */ + (__pyx_v_mslice->shape[__pyx_v_i]) = 1; + + /* "View.MemoryView":1337 + * for i in range(offset): + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< + * mslice.suboffsets[i] = -1 + * + */ + (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); + + /* "View.MemoryView":1338 + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; + } + + /* "View.MemoryView":1324 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1346 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + +static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { + int __pyx_t_1; + + /* "View.MemoryView":1350 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + __pyx_t_1 = (__pyx_v_dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1351 + * + * if dtype_is_object: + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< + * dst.strides, ndim, inc) + * + */ + __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1350 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + } + + /* "View.MemoryView":1346 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + + /* function exit code */ +} + +/* "View.MemoryView":1355 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + +static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + __Pyx_RefNannyDeclarations + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); + + /* "View.MemoryView":1358 + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1355 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif +} + +/* "View.MemoryView":1361 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + +static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); + + /* "View.MemoryView":1365 + * cdef Py_ssize_t i + * + * for i in range(shape[0]): # <<<<<<<<<<<<<< + * if ndim == 1: + * if inc: + */ + __pyx_t_1 = (__pyx_v_shape[0]); + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "View.MemoryView":1366 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + __pyx_t_3 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":1367 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + __pyx_t_3 = (__pyx_v_inc != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":1368 + * if ndim == 1: + * if inc: + * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * Py_DECREF(( data)[0]) + */ + Py_INCREF((((PyObject **)__pyx_v_data)[0])); + + /* "View.MemoryView":1367 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + goto __pyx_L6; + } + + /* "View.MemoryView":1370 + * Py_INCREF(( data)[0]) + * else: + * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + */ + /*else*/ { + Py_DECREF((((PyObject **)__pyx_v_data)[0])); + } + __pyx_L6:; + + /* "View.MemoryView":1366 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + goto __pyx_L5; + } + + /* "View.MemoryView":1372 + * Py_DECREF(( data)[0]) + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, inc) + * + */ + /*else*/ { + + /* "View.MemoryView":1373 + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + * ndim - 1, inc) # <<<<<<<<<<<<<< + * + * data += strides[0] + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc); + } + __pyx_L5:; + + /* "View.MemoryView":1375 + * ndim - 1, inc) + * + * data += strides[0] # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); + } + + /* "View.MemoryView":1361 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1381 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + +static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { + + /* "View.MemoryView":1384 + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1385 + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1387 + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1381 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + +static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_extent; + int __pyx_t_1; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + + /* "View.MemoryView":1395 + * size_t itemsize, void *item) nogil: + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t extent = shape[0] + * + */ + __pyx_v_stride = (__pyx_v_strides[0]); + + /* "View.MemoryView":1396 + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] + * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< + * + * if ndim == 1: + */ + __pyx_v_extent = (__pyx_v_shape[0]); + + /* "View.MemoryView":1398 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1399 + * + * if ndim == 1: + * for i in range(extent): # <<<<<<<<<<<<<< + * memcpy(data, item, itemsize) + * data += stride + */ + __pyx_t_2 = __pyx_v_extent; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1400 + * if ndim == 1: + * for i in range(extent): + * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< + * data += stride + * else: + */ + memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize); + + /* "View.MemoryView":1401 + * for i in range(extent): + * memcpy(data, item, itemsize) + * data += stride # <<<<<<<<<<<<<< + * else: + * for i in range(extent): + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + + /* "View.MemoryView":1398 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1403 + * data += stride + * else: + * for i in range(extent): # <<<<<<<<<<<<<< + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + */ + /*else*/ { + __pyx_t_2 = __pyx_v_extent; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1404 + * else: + * for i in range(extent): + * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, itemsize, item) + * data += stride + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1406 + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + * data += stride # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + } + __pyx_L3:; + + /* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + + /* function exit code */ +} +static struct __pyx_vtabstruct_array __pyx_vtable_array; + +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_array_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_array_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_array; + p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_array(PyObject *o) { + struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_array___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->mode); + Py_CLEAR(p->_format); + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_array___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) { + PyObject *v = PyObject_GenericGetAttr(o, n); + if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + v = __pyx_array___getattr__(o, n); + } + return v; +} + +static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o); +} + +static PyMethodDef __pyx_methods_array[] = { + {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_array[] = { + {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_array = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_array, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_array = { + 0, /*mp_length*/ + __pyx_array___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_array = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_array_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_array = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.array", /*tp_name*/ + sizeof(struct __pyx_array_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_array, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_array, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_array, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + __pyx_tp_getattro_array, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_array, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_array, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_array, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_array, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_MemviewEnum_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_MemviewEnum_obj *)o); + p->name = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_Enum(PyObject *o) { + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->name); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + if (p->name) { + e = (*v)(p->name, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_Enum(PyObject *o) { + PyObject* tmp; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + tmp = ((PyObject*)p->name); + p->name = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_Enum[] = { + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_MemviewEnum = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.Enum", /*tp_name*/ + sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_Enum, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_MemviewEnum___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_Enum, /*tp_traverse*/ + __pyx_tp_clear_Enum, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_Enum, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_MemviewEnum___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_Enum, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview; + +static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryview_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryview_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_memoryview; + p->obj = Py_None; Py_INCREF(Py_None); + p->_size = Py_None; Py_INCREF(Py_None); + p->_array_interface = Py_None; Py_INCREF(Py_None); + p->view.obj = NULL; + if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_memoryview(PyObject *o) { + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_memoryview___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->obj); + Py_CLEAR(p->_size); + Py_CLEAR(p->_array_interface); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + if (p->obj) { + e = (*v)(p->obj, a); if (e) return e; + } + if (p->_size) { + e = (*v)(p->_size, a); if (e) return e; + } + if (p->_array_interface) { + e = (*v)(p->_array_interface, a); if (e) return e; + } + if (p->view.obj) { + e = (*v)(p->view.obj, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_memoryview(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + tmp = ((PyObject*)p->obj); + p->obj = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_size); + p->_size = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_array_interface); + p->_array_interface = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + Py_CLEAR(p->view.obj); + return 0; +} +static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_memoryview___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o); +} + +static PyMethodDef __pyx_methods_memoryview[] = { + {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0}, + {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, + {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, + {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_memoryview[] = { + {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0}, + {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0}, + {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0}, + {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0}, + {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0}, + {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0}, + {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0}, + {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0}, + {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_memoryview = { + __pyx_memoryview___len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_memoryview, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_memoryview = { + __pyx_memoryview___len__, /*mp_length*/ + __pyx_memoryview___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_memoryview = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_memoryview_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_memoryview = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance.memoryview", /*tp_name*/ + sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_memoryview, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_memoryview___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_memoryview___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_memoryview, /*tp_traverse*/ + __pyx_tp_clear_memoryview, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_memoryview, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_memoryview, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_memoryview, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice; + +static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryviewslice_obj *p; + PyObject *o = __pyx_tp_new_memoryview(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryviewslice_obj *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice; + p->from_object = Py_None; Py_INCREF(Py_None); + p->from_slice.memview = NULL; + return o; +} + +static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_memoryviewslice___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->from_object); + PyObject_GC_Track(o); + __pyx_tp_dealloc_memoryview(o); +} + +static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e; + if (p->from_object) { + e = (*v)(p->from_object, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear__memoryviewslice(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + __pyx_tp_clear_memoryview(o); + tmp = ((PyObject*)p->from_object); + p->from_object = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + __PYX_XDEC_MEMVIEW(&p->from_slice, 1); + return 0; +} + +static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o); +} + +static PyMethodDef __pyx_methods__memoryviewslice[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = { + {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_memoryviewslice = { + PyVarObject_HEAD_INIT(0, 0) + "Orange.distance._distance._memoryviewslice", /*tp_name*/ + sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___str__, /*tp_str*/ + #else + 0, /*tp_str*/ + #endif + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Internal class for passing memoryview slices to Python", /*tp_doc*/ + __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/ + __pyx_tp_clear__memoryviewslice, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods__memoryviewslice, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets__memoryviewslice, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new__memoryviewslice, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "_distance", + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1}, + {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0}, + {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0}, + {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1}, + {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, + {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0}, + {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0}, + {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, + {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, + {&__pyx_n_s_Orange_distance__distance, __pyx_k_Orange_distance__distance, sizeof(__pyx_k_Orange_distance__distance), 0, 0, 1, 1}, + {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_abs1, __pyx_k_abs1, sizeof(__pyx_k_abs1), 0, 0, 1, 1}, + {&__pyx_n_s_abs2, __pyx_k_abs2, sizeof(__pyx_k_abs2), 0, 0, 1, 1}, + {&__pyx_n_s_abss, __pyx_k_abss, sizeof(__pyx_k_abss), 0, 0, 1, 1}, + {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, + {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, + {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, + {&__pyx_n_s_col1, __pyx_k_col1, sizeof(__pyx_k_col1), 0, 0, 1, 1}, + {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, + {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_cosine_cols, __pyx_k_cosine_cols, sizeof(__pyx_k_cosine_cols), 0, 0, 1, 1}, + {&__pyx_n_s_cosine_rows, __pyx_k_cosine_rows, sizeof(__pyx_k_cosine_rows), 0, 0, 1, 1}, + {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, + {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, + {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, + {&__pyx_n_s_distances, __pyx_k_distances, sizeof(__pyx_k_distances), 0, 0, 1, 1}, + {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, + {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, + {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, + {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, + {&__pyx_n_s_euclidean_rows_discrete, __pyx_k_euclidean_rows_discrete, sizeof(__pyx_k_euclidean_rows_discrete), 0, 0, 1, 1}, + {&__pyx_n_s_fit_params, __pyx_k_fit_params, sizeof(__pyx_k_fit_params), 0, 0, 1, 1}, + {&__pyx_n_s_fix_euclidean_cols, __pyx_k_fix_euclidean_cols, sizeof(__pyx_k_fix_euclidean_cols), 0, 0, 1, 1}, + {&__pyx_n_s_fix_euclidean_cols_normalized, __pyx_k_fix_euclidean_cols_normalized, sizeof(__pyx_k_fix_euclidean_cols_normalized), 0, 0, 1, 1}, + {&__pyx_n_s_fix_euclidean_rows, __pyx_k_fix_euclidean_rows, sizeof(__pyx_k_fix_euclidean_rows), 0, 0, 1, 1}, + {&__pyx_n_s_fix_euclidean_rows_normalized, __pyx_k_fix_euclidean_rows_normalized, sizeof(__pyx_k_fix_euclidean_rows_normalized), 0, 0, 1, 1}, + {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, + {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, + {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, + {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, + {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_in1_unk2, __pyx_k_in1_unk2, sizeof(__pyx_k_in1_unk2), 0, 0, 1, 1}, + {&__pyx_n_s_in_both, __pyx_k_in_both, sizeof(__pyx_k_in_both), 0, 0, 1, 1}, + {&__pyx_n_s_in_one, __pyx_k_in_one, sizeof(__pyx_k_in_one), 0, 0, 1, 1}, + {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, + {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, + {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, + {&__pyx_n_s_ival1, __pyx_k_ival1, sizeof(__pyx_k_ival1), 0, 0, 1, 1}, + {&__pyx_n_s_ival2, __pyx_k_ival2, sizeof(__pyx_k_ival2), 0, 0, 1, 1}, + {&__pyx_n_s_jaccard_cols, __pyx_k_jaccard_cols, sizeof(__pyx_k_jaccard_cols), 0, 0, 1, 1}, + {&__pyx_n_s_jaccard_rows, __pyx_k_jaccard_rows, sizeof(__pyx_k_jaccard_rows), 0, 0, 1, 1}, + {&__pyx_n_s_mads, __pyx_k_mads, sizeof(__pyx_k_mads), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_manhattan_cols, __pyx_k_manhattan_cols, sizeof(__pyx_k_manhattan_cols), 0, 0, 1, 1}, + {&__pyx_n_s_manhattan_rows, __pyx_k_manhattan_rows, sizeof(__pyx_k_manhattan_rows), 0, 0, 1, 1}, + {&__pyx_n_s_means, __pyx_k_means, sizeof(__pyx_k_means), 0, 0, 1, 1}, + {&__pyx_n_s_medians, __pyx_k_medians, sizeof(__pyx_k_medians), 0, 0, 1, 1}, + {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, + {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, + {&__pyx_n_s_n_cols, __pyx_k_n_cols, sizeof(__pyx_k_n_cols), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows, __pyx_k_n_rows, sizeof(__pyx_k_n_rows), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows1, __pyx_k_n_rows1, sizeof(__pyx_k_n_rows1), 0, 0, 1, 1}, + {&__pyx_n_s_n_rows2, __pyx_k_n_rows2, sizeof(__pyx_k_n_rows2), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, + {&__pyx_n_s_nonnans, __pyx_k_nonnans, sizeof(__pyx_k_nonnans), 0, 0, 1, 1}, + {&__pyx_n_s_nonzeros, __pyx_k_nonzeros, sizeof(__pyx_k_nonzeros), 0, 0, 1, 1}, + {&__pyx_n_s_normalize, __pyx_k_normalize, sizeof(__pyx_k_normalize), 0, 0, 1, 1}, + {&__pyx_n_s_not1_unk2, __pyx_k_not1_unk2, sizeof(__pyx_k_not1_unk2), 0, 0, 1, 1}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, + {&__pyx_n_s_p_nonzero, __pyx_k_p_nonzero, sizeof(__pyx_k_p_nonzero), 0, 0, 1, 1}, + {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, + {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 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_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, + {&__pyx_n_s_row1, __pyx_k_row1, sizeof(__pyx_k_row1), 0, 0, 1, 1}, + {&__pyx_n_s_row2, __pyx_k_row2, sizeof(__pyx_k_row2), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, + {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, + {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1}, + {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, + {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_two_tables, __pyx_k_two_tables, sizeof(__pyx_k_two_tables), 0, 0, 1, 1}, + {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, + {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, + {&__pyx_n_s_union, __pyx_k_union, sizeof(__pyx_k_union), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_in2, __pyx_k_unk1_in2, sizeof(__pyx_k_unk1_in2), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_not2, __pyx_k_unk1_not2, sizeof(__pyx_k_unk1_not2), 0, 0, 1, 1}, + {&__pyx_n_s_unk1_unk2, __pyx_k_unk1_unk2, sizeof(__pyx_k_unk1_unk2), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, + {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1}, + {&__pyx_n_s_val1, __pyx_k_val1, sizeof(__pyx_k_val1), 0, 0, 1, 1}, + {&__pyx_n_s_val2, __pyx_k_val2, sizeof(__pyx_k_val2), 0, 0, 1, 1}, + {&__pyx_n_s_vars, __pyx_k_vars, sizeof(__pyx_k_vars), 0, 0, 1, 1}, + {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, + {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1}, + {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1}, + {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) + __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 396, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 425, __pyx_L1_error) + __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 599, __pyx_L1_error) + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 818, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "Orange/distance/_distance.pyx":440 + * for col1 in range(n_cols): + * if vars[col1] == -2: + * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< + * continue + * with nogil: + */ + __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * if ((descr.byteorder == c'>' and little_endian) or + * (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" + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "View.MemoryView":131 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "View.MemoryView":134 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "View.MemoryView":137 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "View.MemoryView":146 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "View.MemoryView":174 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + /* "View.MemoryView":190 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len + */ + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + /* "View.MemoryView":484 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 484, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + + /* "View.MemoryView":556 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + */ + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + + /* "View.MemoryView":563 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + */ + __pyx_tuple__17 = PyTuple_New(1); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_tuple__17, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__17); + + /* "View.MemoryView":668 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: + */ + __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + + /* "View.MemoryView":671 + * seen_ellipsis = True + * else: + * result.append(slice(None)) # <<<<<<<<<<<<<< + * have_slices = True + * else: + */ + __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 671, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + + /* "View.MemoryView":682 + * nslices = ndim - len(result) + * if nslices: + * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + * + * return have_slices or nslices, tuple(result) + */ + __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__20); + __Pyx_GIVEREF(__pyx_slice__20); + + /* "View.MemoryView":689 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + + /* "Orange/distance/_distance.pyx":25 + * + * + * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, + */ + __pyx_tuple__22 = PyTuple_Pack(17, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 25, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(6, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows_discrete, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 25, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":59 + * + * + * def fix_euclidean_rows( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, + */ + __pyx_tuple__24 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 59, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":94 + * + * + * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, + */ + __pyx_tuple__26 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows_normalized, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 94, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":129 + * + * + * def fix_euclidean_cols( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, + */ + __pyx_tuple__28 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 129, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":159 + * + * + * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, + */ + __pyx_tuple__30 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols_normalized, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 159, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":188 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_tuple__32 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); + __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 188, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":251 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + __pyx_tuple__34 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__34); + __Pyx_GIVEREF(__pyx_tuple__34); + __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 251, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 251, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":296 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + __pyx_tuple__36 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__36); + __Pyx_GIVEREF(__pyx_tuple__36); + __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 296, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 296, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":340 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_tuple__38 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 340, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__38); + __Pyx_GIVEREF(__pyx_tuple__38); + __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 340, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":422 + * + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] + */ + __pyx_tuple__40 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__40); + __Pyx_GIVEREF(__pyx_tuple__40); + __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 422, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":467 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_tuple__42 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 467, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__42); + __Pyx_GIVEREF(__pyx_tuple__42); + __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 467, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 467, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":518 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + __pyx_tuple__44 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__44); + __Pyx_GIVEREF(__pyx_tuple__44); + __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 518, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 518, __pyx_L1_error) + + /* "View.MemoryView":282 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__46); + __Pyx_GIVEREF(__pyx_tuple__46); + + /* "View.MemoryView":283 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__47); + __Pyx_GIVEREF(__pyx_tuple__47); + + /* "View.MemoryView":284 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__48); + __Pyx_GIVEREF(__pyx_tuple__48); + + /* "View.MemoryView":287 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__49); + __Pyx_GIVEREF(__pyx_tuple__49); + + /* "View.MemoryView":288 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__50); + __Pyx_GIVEREF(__pyx_tuple__50); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_distance(void); /*proto*/ +PyMODINIT_FUNC init_distance(void) +#else +PyMODINIT_FUNC PyInit__distance(void); /*proto*/ +PyMODINIT_FUNC PyInit__distance(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + static PyThread_type_lock __pyx_t_2[8]; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__distance(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("_distance", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_Orange__distance___distance) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "Orange.distance._distance")) { + if (unlikely(PyDict_SetItemString(modules, "Orange.distance._distance", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + generic = Py_None; Py_INCREF(Py_None); + strided = Py_None; Py_INCREF(Py_None); + indirect = Py_None; Py_INCREF(Py_None); + contiguous = Py_None; Py_INCREF(Py_None); + indirect_contiguous = Py_None; Py_INCREF(Py_None); + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_array = &__pyx_vtable_array; + __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; + if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) + __pyx_type___pyx_array.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) + __pyx_array_type = &__pyx_type___pyx_array; + if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 275, __pyx_L1_error) + __pyx_type___pyx_MemviewEnum.tp_print = 0; + __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; + __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; + __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; + __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice; + __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment; + __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar; + __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed; + __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object; + __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object; + if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) + __pyx_type___pyx_memoryview.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) + __pyx_memoryview_type = &__pyx_type___pyx_memoryview; + __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; + __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; + __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; + __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; + __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; + if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) + __pyx_type___pyx_memoryviewslice.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) + __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "Orange/distance/_distance.pyx":7 + * #cython: wraparound=False + * + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":25 + * + * + * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows_discrete, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows_discrete, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":59 + * + * + * def fix_euclidean_rows( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3fix_euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":94 + * + * + * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x1, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":129 + * + * + * def fix_euclidean_cols( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":159 + * + * + * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] distances, + * np.ndarray[np.float64_t, ndim=2] x, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":188 + * + * + * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":251 + * + * + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] medians = fit_params["medians"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":296 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":340 + * + * + * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":422 + * + * + * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] vars = fit_params["vars"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_19cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":467 + * + * + * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_21jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 467, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":518 + * + * + * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * cdef: + * double [:] ps = fit_params["ps"] + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_23jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":1 + * #cython: embedsignature=True # <<<<<<<<<<<<<< + * #cython: infer_types=True + * #cython: cdivision=True + */ + __pyx_t_1 = PyDict_New(); 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; + + /* "View.MemoryView":207 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * def __dealloc__(array self): + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 207, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_array_type); + + /* "View.MemoryView":282 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(generic); + __Pyx_DECREF_SET(generic, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":283 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(strided); + __Pyx_DECREF_SET(strided, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":284 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(indirect); + __Pyx_DECREF_SET(indirect, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":287 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(contiguous); + __Pyx_DECREF_SET(contiguous, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":288 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(indirect_contiguous); + __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":312 + * + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<< + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ + * PyThread_allocate_lock(), + */ + __pyx_memoryview_thread_locks_used = 0; + + /* "View.MemoryView":313 + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<< + * PyThread_allocate_lock(), + * PyThread_allocate_lock(), + */ + __pyx_t_2[0] = PyThread_allocate_lock(); + __pyx_t_2[1] = PyThread_allocate_lock(); + __pyx_t_2[2] = PyThread_allocate_lock(); + __pyx_t_2[3] = PyThread_allocate_lock(); + __pyx_t_2[4] = PyThread_allocate_lock(); + __pyx_t_2[5] = PyThread_allocate_lock(); + __pyx_t_2[6] = PyThread_allocate_lock(); + __pyx_t_2[7] = PyThread_allocate_lock(); + memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); + + /* "View.MemoryView":535 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 535, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 535, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_memoryview_type); + + /* "View.MemoryView":981 + * return self.from_object + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 981, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 981, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_memoryviewslice_type); + + /* "View.MemoryView":1391 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init Orange.distance._distance", __pyx_clineno, __pyx_lineno, __pyx_filename); } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init Orange.distance._distance"); } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif } -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; } -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + return result; +} + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } + num_expected = num_max; + more_or_less = "at most"; } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; + if (exact) { + more_or_less = "exactly"; } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; } -static CYTHON_INLINE PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) + +/* ArgTypeTest */ +static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) { - const char *ts = *tsp; - int i = 0, number; - int ndim = ctx->head->field->type->ndim; -; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; } -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_IsLittleEndian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_IsLittleEndian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if (ctx->enc_type == *ts && got_Z == ctx->is_complex && - ctx->enc_packmode == ctx->new_packmode) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; + +/* BufferFormatCheck */ +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; } } - } + *ts = t; + return count; } -static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; } -static CYTHON_INLINE int __Pyx_GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - if (obj == Py_None || obj == NULL) { - __Pyx_ZeroBuffer(buf); - return 0; - } - buf->buf = NULL; - if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; - if (buf->ndim != nd) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if ((unsigned)buf->itemsize != dtype->size) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_ZeroBuffer(buf); - return -1; +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); } -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (info->buf == NULL) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } } - -/* MemviewSliceInit */ - static int -__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, - int ndim, - __Pyx_memviewslice *memviewslice, - int memview_is_new_reference) -{ - __Pyx_RefNannyDeclarations - int i, retval=-1; - Py_buffer *buf = &memview->view; - __Pyx_RefNannySetupContext("init_memviewslice", 0); - if (!buf) { - PyErr_SetString(PyExc_ValueError, - "buf is NULL."); - goto fail; - } else if (memviewslice->memview || memviewslice->data) { - PyErr_SetString(PyExc_ValueError, - "memviewslice is already initialized!"); - goto fail; - } - if (buf->strides) { - for (i = 0; i < ndim; i++) { - memviewslice->strides[i] = buf->strides[i]; - } - } else { - Py_ssize_t stride = buf->itemsize; - for (i = ndim - 1; i >= 0; i--) { - memviewslice->strides[i] = stride; - stride *= buf->shape[i]; - } +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; } - for (i = 0; i < ndim; i++) { - memviewslice->shape[i] = buf->shape[i]; - if (buf->suboffsets) { - memviewslice->suboffsets[i] = buf->suboffsets[i]; - } else { - memviewslice->suboffsets[i] = -1; - } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; } - memviewslice->memview = memview; - memviewslice->data = (char *)buf->buf; - if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { - Py_INCREF(memview); +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; } - retval = 0; - goto no_fail; -fail: - memviewslice->memview = 0; - memviewslice->data = 0; - retval = -1; -no_fail: - __Pyx_RefNannyFinishContext(); - return retval; + } } -static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) { - va_list vargs; - char msg[200]; -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, fmt); -#else - va_start(vargs); +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif - vsnprintf(msg, 200, fmt, vargs); - Py_FatalError(msg); - va_end(vargs); -} -static CYTHON_INLINE int -__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, - PyThread_type_lock lock) -{ - int result; - PyThread_acquire_lock(lock, 1); - result = (*acquisition_count)++; - PyThread_release_lock(lock); - return result; +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } } -static CYTHON_INLINE int -__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, - PyThread_type_lock lock) -{ - int result; - PyThread_acquire_lock(lock, 1); - result = (*acquisition_count)--; - PyThread_release_lock(lock); - return result; +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } } -static CYTHON_INLINE void -__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno) -{ - int first_time; - struct __pyx_memoryview_obj *memview = memslice->memview; - if (!memview || (PyObject *) memview == Py_None) - return; - if (__pyx_get_slice_count(memview) < 0) - __pyx_fatalerror("Acquisition count is %d (line %d)", - __pyx_get_slice_count(memview), lineno); - first_time = __pyx_add_acquisition_count(memview) == 0; - if (first_time) { - if (have_gil) { - Py_INCREF((PyObject *) memview); - } else { - PyGILState_STATE _gilstate = PyGILState_Ensure(); - Py_INCREF((PyObject *) memview); - PyGILState_Release(_gilstate); - } +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; } + } } -static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, - int have_gil, int lineno) { - int last_time; - struct __pyx_memoryview_obj *memview = memslice->memview; - if (!memview ) { - return; - } else if ((PyObject *) memview == Py_None) { - memslice->memview = NULL; - return; +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; } - if (__pyx_get_slice_count(memview) <= 0) - __pyx_fatalerror("Acquisition count is %d (line %d)", - __pyx_get_slice_count(memview), lineno); - last_time = __pyx_sub_acquisition_count(memview) == 1; - memslice->data = NULL; - if (last_time) { - if (have_gil) { - Py_CLEAR(memslice->memview); - } else { - PyGILState_STATE _gilstate = PyGILState_Ensure(); - Py_CLEAR(memslice->memview); - PyGILState_Release(_gilstate); + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { - memslice->memview = NULL; + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); } -} - -/* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); } - return result; -} -#endif - -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } } - return result; -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; } + break; + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; } -#endif - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; } + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* PyErrFetchRestore */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; } -#endif - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } + break; + case '}': + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; } - } else { - PyErr_SetString(PyExc_TypeError, - "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 (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = PyThreadState_GET(); - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); + case 's': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; } -#endif } -bad: - Py_XDECREF(owned_instance); - return; + } } -#endif - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); } -/* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) +/* MemviewSliceInit */ + static int +__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference) { - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; + __Pyx_RefNannyDeclarations + int i, retval=-1; + Py_buffer *buf = &memview->view; + __Pyx_RefNannySetupContext("init_memviewslice", 0); + if (!buf) { + PyErr_SetString(PyExc_ValueError, + "buf is NULL."); + goto fail; + } else if (memviewslice->memview || memviewslice->data) { + PyErr_SetString(PyExc_ValueError, + "memviewslice is already initialized!"); + goto fail; + } + if (buf->strides) { + for (i = 0; i < ndim; i++) { + memviewslice->strides[i] = buf->strides[i]; + } } else { - num_expected = num_max; - more_or_less = "at most"; + Py_ssize_t stride = buf->itemsize; + for (i = ndim - 1; i >= 0; i--) { + memviewslice->strides[i] = stride; + stride *= buf->shape[i]; + } } - if (exact) { - more_or_less = "exactly"; + for (i = 0; i < ndim; i++) { + memviewslice->shape[i] = buf->shape[i]; + if (buf->suboffsets) { + memviewslice->suboffsets[i] = buf->suboffsets[i]; + } else { + memviewslice->suboffsets[i] = -1; + } } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); + memviewslice->memview = memview; + memviewslice->data = (char *)buf->buf; + if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { + Py_INCREF(memview); + } + retval = 0; + goto no_fail; +fail: + memviewslice->memview = 0; + memviewslice->data = 0; + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} +static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) { + va_list vargs; + char msg[200]; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, fmt); +#else + va_start(vargs); +#endif + vsnprintf(msg, 200, fmt, vargs); + Py_FatalError(msg); + va_end(vargs); } - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) +static CYTHON_INLINE int +__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) { - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)++; + PyThread_release_lock(lock); + return result; } - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) +static CYTHON_INLINE int +__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) { - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)--; + PyThread_release_lock(lock); + return result; +} +static CYTHON_INLINE void +__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno) +{ + int first_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (!memview || (PyObject *) memview == Py_None) + return; + if (__pyx_get_slice_count(memview) < 0) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + first_time = __pyx_add_acquisition_count(memview) == 0; + if (first_time) { + if (have_gil) { + Py_INCREF((PyObject *) memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_INCREF((PyObject *) memview); + PyGILState_Release(_gilstate); } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } +} +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, + int have_gil, int lineno) { + int last_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (!memview ) { + return; + } else if ((PyObject *) memview == Py_None) { + memslice->memview = NULL; + return; + } + if (__pyx_get_slice_count(memview) <= 0) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + last_time = __pyx_sub_acquisition_count(memview) == 1; + memslice->data = NULL; + if (last_time) { + if (have_gil) { + Py_CLEAR(memslice->memview); } else { - goto invalid_keyword; + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_CLEAR(memslice->memview); + PyGILState_Release(_gilstate); } + } else { + memslice->memview = NULL; } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; } -/* ArgTypeTest */ - static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); +/* PyErrFetchRestore */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); } -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* GetModuleGlobalName */ + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); } - if (none_allowed && obj == Py_None) return 1; - else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; - #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif + return result; +} + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); } - else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + return result; +} +#endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); - return 0; + return result; } +#endif -/* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); + if (likely(PyCFunction_Check(func))) { #endif - result = __Pyx_GetBuiltinName(name); + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); + } } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); return result; } +#endif /* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; @@ -26158,31 +26668,194 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* BufferFallbackError */ - static void __Pyx_RaiseBufferFallbackError(void) { + static void __Pyx_RaiseBufferFallbackError(void) { PyErr_SetString(PyExc_ValueError, "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); } +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + /* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* BytesEquals */ - static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26220,7 +26893,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* UnicodeEquals */ - static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26304,7 +26977,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* GetAttr */ - static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { + static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) @@ -26317,7 +26990,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* decode_c_string */ - static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { @@ -26350,7 +27023,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* SaveResetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -26374,7 +27047,7 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { PyObject *exc_type = tstate->curexc_type; if (exc_type == err) return 1; @@ -26384,7 +27057,7 @@ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tsta #endif /* GetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -26445,7 +27118,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SwapException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -26470,7 +27143,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, #endif /* Import */ - 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; @@ -26544,7 +27217,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, } /* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); @@ -26625,7 +27298,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, } /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -26723,12 +27396,54 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED #endif /* None */ - static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + /* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else @@ -26746,7 +27461,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; @@ -26826,7 +27541,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -26929,8 +27644,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif - /* MemviewSliceIsContig */ - static int + /* MemviewSliceIsContig */ + static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim) { @@ -26944,65 +27659,311 @@ __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, start = ndim - 1; } for (i = 0; i < ndim; i++) { - index = start + step * i; - if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) - return 0; - itemsize *= mvs.shape[index]; + index = start + step * i; + if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) + return 0; + itemsize *= mvs.shape[index]; + } + return 1; +} + +/* OverlappingSlices */ + static void +__pyx_get_array_memory_extents(__Pyx_memviewslice *slice, + void **out_start, void **out_end, + int ndim, size_t itemsize) +{ + char *start, *end; + int i; + start = end = slice->data; + for (i = 0; i < ndim; i++) { + Py_ssize_t stride = slice->strides[i]; + Py_ssize_t extent = slice->shape[i]; + if (extent == 0) { + *out_start = *out_end = start; + return; + } else { + if (stride > 0) + end += stride * (extent - 1); + else + start += stride * (extent - 1); + } + } + *out_start = start; + *out_end = end + itemsize; +} +static int +__pyx_slices_overlap(__Pyx_memviewslice *slice1, + __Pyx_memviewslice *slice2, + int ndim, size_t itemsize) +{ + void *start1, *end1, *start2, *end2; + __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); + __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); + return (start1 < end2) && (start2 < end1); +} + +/* Capsule */ + static CYTHON_INLINE PyObject * +__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) +{ + PyObject *cobj; +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(p, sig, NULL); +#else + cobj = PyCObject_FromVoidPtr(p, NULL); +#endif + return cobj; +} + +/* TypeInfoCompare */ + static int +__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) +{ + int i; + if (!a || !b) + return 0; + if (a == b) + return 1; + if (a->size != b->size || a->typegroup != b->typegroup || + a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) { + if (a->typegroup == 'H' || b->typegroup == 'H') { + return a->size == b->size; + } else { + return 0; + } + } + if (a->ndim) { + for (i = 0; i < a->ndim; i++) + if (a->arraysize[i] != b->arraysize[i]) + return 0; + } + if (a->typegroup == 'S') { + if (a->flags != b->flags) + return 0; + if (a->fields || b->fields) { + if (!(a->fields && b->fields)) + return 0; + for (i = 0; a->fields[i].type && b->fields[i].type; i++) { + __Pyx_StructField *field_a = a->fields + i; + __Pyx_StructField *field_b = b->fields + i; + if (field_a->offset != field_b->offset || + !__pyx_typeinfo_cmp(field_a->type, field_b->type)) + return 0; + } + return !a->fields[i].type && !b->fields[i].type; + } + } + return 1; +} + +/* MemviewSliceValidateAndInit */ + static int +__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec) +{ + if (buf->shape[dim] <= 1) + return 1; + if (buf->strides) { + if (spec & __Pyx_MEMVIEW_CONTIG) { + if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) { + if (buf->strides[dim] != sizeof(void *)) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly contiguous " + "in dimension %d.", dim); + goto fail; + } + } else if (buf->strides[dim] != buf->itemsize) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + if (spec & __Pyx_MEMVIEW_FOLLOW) { + Py_ssize_t stride = buf->strides[dim]; + if (stride < 0) + stride = -stride; + if (stride < buf->itemsize) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + } else { + if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not contiguous in " + "dimension %d", dim); + goto fail; + } else if (spec & (__Pyx_MEMVIEW_PTR)) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not indirect in " + "dimension %d", dim); + goto fail; + } else if (buf->suboffsets) { + PyErr_SetString(PyExc_ValueError, + "Buffer exposes suboffsets but no strides"); + goto fail; + } + } + return 1; +fail: + return 0; +} +static int +__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec) +{ + if (spec & __Pyx_MEMVIEW_DIRECT) { + if (buf->suboffsets && buf->suboffsets[dim] >= 0) { + PyErr_Format(PyExc_ValueError, + "Buffer not compatible with direct access " + "in dimension %d.", dim); + goto fail; + } + } + if (spec & __Pyx_MEMVIEW_PTR) { + if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly accessible " + "in dimension %d.", dim); + goto fail; + } + } + return 1; +fail: + return 0; +} +static int +__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag) +{ + int i; + if (c_or_f_flag & __Pyx_IS_F_CONTIG) { + Py_ssize_t stride = 1; + for (i = 0; i < ndim; i++) { + if (stride * buf->itemsize != buf->strides[i] && + buf->shape[i] > 1) + { + PyErr_SetString(PyExc_ValueError, + "Buffer not fortran contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) { + Py_ssize_t stride = 1; + for (i = ndim - 1; i >- 1; i--) { + if (stride * buf->itemsize != buf->strides[i] && + buf->shape[i] > 1) { + PyErr_SetString(PyExc_ValueError, + "Buffer not C contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } + return 1; +fail: + return 0; +} +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj) +{ + struct __pyx_memoryview_obj *memview, *new_memview; + __Pyx_RefNannyDeclarations + Py_buffer *buf; + int i, spec = 0, retval = -1; + __Pyx_BufFmt_Context ctx; + int from_memoryview = __pyx_memoryview_check(original_obj); + __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0); + if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *) + original_obj)->typeinfo)) { + memview = (struct __pyx_memoryview_obj *) original_obj; + new_memview = NULL; + } else { + memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + original_obj, buf_flags, 0, dtype); + new_memview = memview; + if (unlikely(!memview)) + goto fail; + } + buf = &memview->view; + if (buf->ndim != ndim) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + ndim, buf->ndim); + goto fail; + } + if (new_memview) { + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned) buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) " + "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)", + buf->itemsize, + (buf->itemsize > 1) ? "s" : "", + dtype->name, + dtype->size, + (dtype->size > 1) ? "s" : ""); + goto fail; + } + for (i = 0; i < ndim; i++) { + spec = axes_specs[i]; + if (!__pyx_check_strides(buf, i, ndim, spec)) + goto fail; + if (!__pyx_check_suboffsets(buf, i, ndim, spec)) + goto fail; } - return 1; -} - -/* OverlappingSlices */ - static void -__pyx_get_array_memory_extents(__Pyx_memviewslice *slice, - void **out_start, void **out_end, - int ndim, size_t itemsize) -{ - char *start, *end; - int i; - start = end = slice->data; - for (i = 0; i < ndim; i++) { - Py_ssize_t stride = slice->strides[i]; - Py_ssize_t extent = slice->shape[i]; - if (extent == 0) { - *out_start = *out_end = start; - return; - } else { - if (stride > 0) - end += stride * (extent - 1); - else - start += stride * (extent - 1); - } + if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)) + goto fail; + if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice, + new_memview != NULL) == -1)) { + goto fail; } - *out_start = start; - *out_end = end + itemsize; -} -static int -__pyx_slices_overlap(__Pyx_memviewslice *slice1, - __Pyx_memviewslice *slice2, - int ndim, size_t itemsize) -{ - void *start1, *end1, *start2, *end2; - __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); - __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); - return (start1 < end2) && (start2 < end1); + retval = 0; + goto no_fail; +fail: + Py_XDECREF(new_memview); + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; } -/* Capsule */ - static CYTHON_INLINE PyObject * -__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) -{ - PyObject *cobj; -#if PY_VERSION_HEX >= 0x02070000 - cobj = PyCapsule_New(p, sig, NULL); -#else - cobj = PyCObject_FromVoidPtr(p, NULL); -#endif - return cobj; +/* ObjectToMemviewSlice */ + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj) { + __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_BufFmt_StackElem stack[1]; + int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; + int retcode; + if (obj == Py_None) { + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, + PyBUF_RECORDS, 2, + &__Pyx_TypeInfo_double, stack, + &result, obj); + if (unlikely(retcode == -1)) + goto __pyx_fail; + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) @@ -27023,20 +27984,31 @@ __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) return (target_type) value;\ } -/* MemviewDtypeToObject */ - static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) { - return (PyObject *) PyFloat_FromDouble(*(double *) itemp); -} -static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) { - double value = __pyx_PyFloat_AsDouble(obj); - if ((value == (double)-1) && PyErr_Occurred()) - return 0; - *(double *) itemp = value; - return 1; +/* ObjectToMemviewSlice */ + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) { + __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_BufFmt_StackElem stack[1]; + int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; + int retcode; + if (obj == Py_None) { + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, + PyBUF_RECORDS, 1, + &__Pyx_TypeInfo_double, stack, + &result, obj); + if (unlikely(retcode == -1)) + goto __pyx_fail; + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27062,8 +28034,20 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } } +/* MemviewDtypeToObject */ + static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) { + return (PyObject *) PyFloat_FromDouble(*(double *) itemp); +} +static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) { + double value = __pyx_PyFloat_AsDouble(obj); + if ((value == (double)-1) && PyErr_Occurred()) + return 0; + *(double *) itemp = value; + return 1; +} + /* None */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); @@ -27083,7 +28067,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif /* None */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -27185,7 +28169,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif /* None */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); @@ -27205,7 +28189,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif /* None */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -27307,7 +28291,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27334,7 +28318,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } /* MemviewSliceCopyTemplate */ - static __Pyx_memviewslice + static __Pyx_memviewslice __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, const char *mode, int ndim, size_t sizeof_dtype, int contig_flag, @@ -27401,7 +28385,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { + static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { const char neg_one = (char) -1, const_zero = (char) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -27586,7 +28570,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -27771,7 +28755,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27798,7 +28782,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -27912,347 +28896,78 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } break; case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* TypeInfoCompare */ - static int -__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) -{ - int i; - if (!a || !b) - return 0; - if (a == b) - return 1; - if (a->size != b->size || a->typegroup != b->typegroup || - a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) { - if (a->typegroup == 'H' || b->typegroup == 'H') { - return a->size == b->size; - } else { - return 0; - } - } - if (a->ndim) { - for (i = 0; i < a->ndim; i++) - if (a->arraysize[i] != b->arraysize[i]) - return 0; - } - if (a->typegroup == 'S') { - if (a->flags != b->flags) - return 0; - if (a->fields || b->fields) { - if (!(a->fields && b->fields)) - return 0; - for (i = 0; a->fields[i].type && b->fields[i].type; i++) { - __Pyx_StructField *field_a = a->fields + i; - __Pyx_StructField *field_b = b->fields + i; - if (field_a->offset != field_b->offset || - !__pyx_typeinfo_cmp(field_a->type, field_b->type)) - return 0; - } - return !a->fields[i].type && !b->fields[i].type; - } - } - return 1; -} - -/* MemviewSliceValidateAndInit */ - static int -__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec) -{ - if (buf->shape[dim] <= 1) - return 1; - if (buf->strides) { - if (spec & __Pyx_MEMVIEW_CONTIG) { - if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) { - if (buf->strides[dim] != sizeof(void *)) { - PyErr_Format(PyExc_ValueError, - "Buffer is not indirectly contiguous " - "in dimension %d.", dim); - goto fail; - } - } else if (buf->strides[dim] != buf->itemsize) { - PyErr_SetString(PyExc_ValueError, - "Buffer and memoryview are not contiguous " - "in the same dimension."); - goto fail; + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; } - } - if (spec & __Pyx_MEMVIEW_FOLLOW) { - Py_ssize_t stride = buf->strides[dim]; - if (stride < 0) - stride = -stride; - if (stride < buf->itemsize) { - PyErr_SetString(PyExc_ValueError, - "Buffer and memoryview are not contiguous " - "in the same dimension."); - goto fail; +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } - } else { - if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) { - PyErr_Format(PyExc_ValueError, - "C-contiguous buffer is not contiguous in " - "dimension %d", dim); - goto fail; - } else if (spec & (__Pyx_MEMVIEW_PTR)) { - PyErr_Format(PyExc_ValueError, - "C-contiguous buffer is not indirect in " - "dimension %d", dim); - goto fail; - } else if (buf->suboffsets) { - PyErr_SetString(PyExc_ValueError, - "Buffer exposes suboffsets but no strides"); - goto fail; - } - } - return 1; -fail: - return 0; -} -static int -__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec) -{ - if (spec & __Pyx_MEMVIEW_DIRECT) { - if (buf->suboffsets && buf->suboffsets[dim] >= 0) { - PyErr_Format(PyExc_ValueError, - "Buffer not compatible with direct access " - "in dimension %d.", dim); - goto fail; - } - } - if (spec & __Pyx_MEMVIEW_PTR) { - if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) { - PyErr_Format(PyExc_ValueError, - "Buffer is not indirectly accessible " - "in dimension %d.", dim); - goto fail; - } - } - return 1; -fail: - return 0; -} -static int -__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag) -{ - int i; - if (c_or_f_flag & __Pyx_IS_F_CONTIG) { - Py_ssize_t stride = 1; - for (i = 0; i < ndim; i++) { - if (stride * buf->itemsize != buf->strides[i] && - buf->shape[i] > 1) - { - PyErr_SetString(PyExc_ValueError, - "Buffer not fortran contiguous."); - goto fail; + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); } - stride = stride * buf->shape[i]; - } - } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) { - Py_ssize_t stride = 1; - for (i = ndim - 1; i >- 1; i--) { - if (stride * buf->itemsize != buf->strides[i] && - buf->shape[i] > 1) { - PyErr_SetString(PyExc_ValueError, - "Buffer not C contiguous."); - goto fail; + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; } - stride = stride * buf->shape[i]; +#endif + return (long) -1; } - } - return 1; -fail: - return 0; -} -static int __Pyx_ValidateAndInit_memviewslice( - int *axes_specs, - int c_or_f_flag, - int buf_flags, - int ndim, - __Pyx_TypeInfo *dtype, - __Pyx_BufFmt_StackElem stack[], - __Pyx_memviewslice *memviewslice, - PyObject *original_obj) -{ - struct __pyx_memoryview_obj *memview, *new_memview; - __Pyx_RefNannyDeclarations - Py_buffer *buf; - int i, spec = 0, retval = -1; - __Pyx_BufFmt_Context ctx; - int from_memoryview = __pyx_memoryview_check(original_obj); - __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0); - if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *) - original_obj)->typeinfo)) { - memview = (struct __pyx_memoryview_obj *) original_obj; - new_memview = NULL; } else { - memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( - original_obj, buf_flags, 0, dtype); - new_memview = memview; - if (unlikely(!memview)) - goto fail; - } - buf = &memview->view; - if (buf->ndim != ndim) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - ndim, buf->ndim); - goto fail; - } - if (new_memview) { - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if ((unsigned) buf->itemsize != dtype->size) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) " - "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)", - buf->itemsize, - (buf->itemsize > 1) ? "s" : "", - dtype->name, - dtype->size, - (dtype->size > 1) ? "s" : ""); - goto fail; - } - for (i = 0; i < ndim; i++) { - spec = axes_specs[i]; - if (!__pyx_check_strides(buf, i, ndim, spec)) - goto fail; - if (!__pyx_check_suboffsets(buf, i, ndim, spec)) - goto fail; - } - if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)) - goto fail; - if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice, - new_memview != NULL) == -1)) { - goto fail; - } - retval = 0; - goto no_fail; -fail: - Py_XDECREF(new_memview); - retval = -1; -no_fail: - __Pyx_RefNannyFinishContext(); - return retval; -} - -/* ObjectToMemviewSlice */ - static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) { - __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_BufFmt_StackElem stack[1]; - int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; - int retcode; - if (obj == Py_None) { - result.memview = (struct __pyx_memoryview_obj *) Py_None; - return result; - } - retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, - PyBUF_RECORDS, 1, - &__Pyx_TypeInfo_double, stack, - &result, obj); - if (unlikely(retcode == -1)) - goto __pyx_fail; - return result; -__pyx_fail: - result.memview = NULL; - result.data = NULL; - return result; -} - -/* ObjectToMemviewSlice */ - static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj) { - __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_BufFmt_StackElem stack[1]; - int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; - int retcode; - if (obj == Py_None) { - result.memview = (struct __pyx_memoryview_obj *) Py_None; - return result; + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; } - retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, - PyBUF_RECORDS, 2, - &__Pyx_TypeInfo_double, stack, - &result, obj); - if (unlikely(retcode == -1)) - goto __pyx_fail; - return result; -__pyx_fail: - result.memview = NULL; - result.data = NULL; - return result; +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; } /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); @@ -28268,7 +28983,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -28286,7 +29001,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -28351,7 +29066,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index db48a3b1d47..1484aef9772 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -15,14 +15,6 @@ cdef extern from "math.h": double sqrt(double x) nogil -# This function is unused, but kept here for any future use -cdef void _check_division_by_zero(double[:, :] x, double[:] dividers): - cdef int col - for col in range(dividers.shape[0]): - if dividers[col] == 0 and not x[:, col].isnan().all(): - raise ValueError("cannot normalize: the data has no variance") - - cdef void _lower_to_symmetric(double [:, :] distances): cdef int row1, row2 for row1 in range(distances.shape[0]): @@ -30,109 +22,167 @@ cdef void _lower_to_symmetric(double [:, :] distances): distances[row2, row1] = distances[row1, row2] -def euclidean_rows(np.ndarray[np.float64_t, ndim=2] x1, - np.ndarray[np.float64_t, ndim=2] x2, - char two_tables, - fit_params): +def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + double[:, :] dist_missing, + np.ndarray[np.float64_t, ndim=1] dist_missing2, + char two_tables): cdef: - double [:] vars = fit_params["vars"] - double [:] means = fit_params["means"] - double [:, :] dist_missing = fit_params["dist_missing"] - double [:] dist_missing2 = fit_params["dist_missing2"] - char normalize = fit_params["normalize"] - int n_rows1, n_rows2, n_cols, row1, row2, col double val1, val2, d int ival1, ival2 - double [:, :] distances n_rows1, n_cols = x1.shape[0], x1.shape[1] n_rows2 = x2.shape[0] - assert n_cols == x2.shape[1] == len(vars) == len(means) \ - == len(dist_missing) == len(dist_missing2) - distances = np.zeros((n_rows1, n_rows2), dtype=float) - with nogil: for row1 in range(n_rows1): for row2 in range(n_rows2 if two_tables else row1): d = 0 for col in range(n_cols): - if vars[col] == -2: - continue val1, val2 = x1[row1, col], x2[row2, col] - if npy_isnan(val1) and npy_isnan(val2): - d += dist_missing2[col] - elif vars[col] == -1: - ival1, ival2 = int(val1), int(val2) - if npy_isnan(val1): + ival1, ival2 = int(val1), int(val2) + if npy_isnan(val1): + if npy_isnan(val2): + d += dist_missing2[col] + else: d += dist_missing[col, ival2] - elif npy_isnan(val2): - d += dist_missing[col, ival1] - elif ival1 != ival2: - d += 1 - elif normalize: + elif npy_isnan(val2): + d += dist_missing[col, ival1] + elif ival1 != ival2: + d += 1 + distances[row1, row2] += d + if not two_tables: + _lower_to_symmetric(distances) + + +def fix_euclidean_rows( + np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + np.ndarray[np.float64_t, ndim=1] means, + np.ndarray[np.float64_t, ndim=1] vars, + np.ndarray[np.float64_t, ndim=1] dist_missing2, + char two_tables): + cdef: + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + if npy_isnan(distances[row1, row2]): + d = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x2[row2, col] if npy_isnan(val1): - d += (val2 - means[col]) ** 2 / vars[col] / 2 + 0.5 + if npy_isnan(val2): + d += dist_missing2[col] + else: + d += (val2 - means[col]) ** 2 + vars[col] elif npy_isnan(val2): - d += (val1 - means[col]) ** 2 / vars[col] / 2 + 0.5 + d += (val1 - means[col]) ** 2 + vars[col] else: - d += ((val1 - val2) ** 2 / vars[col]) / 2 - else: + d += (val1 - val2) ** 2 + distances[row1, row2] = d + if not two_tables: + distances[row2, row1] = d + + +def fix_euclidean_rows_normalized( + np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + np.ndarray[np.float64_t, ndim=1] means, + np.ndarray[np.float64_t, ndim=1] vars, + np.ndarray[np.float64_t, ndim=1] dist_missing2, + char two_tables): + cdef: + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + if npy_isnan(distances[row1, row2]): + d = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x2[row2, col] if npy_isnan(val1): - d += (val2 - means[col]) ** 2 + vars[col] + if npy_isnan(val2): + d += dist_missing2[col] + else: + d += val2 ** 2 + 0.5 elif npy_isnan(val2): - d += (val1 - means[col]) ** 2 + vars[col] + d += val1 ** 2 + 0.5 else: d += (val1 - val2) ** 2 - distances[row1, row2] = d - if not two_tables: - _lower_to_symmetric(distances) - return np.sqrt(distances) + distances[row1, row2] = d + if not two_tables: + distances[row2, row1] = d -def euclidean_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): +def fix_euclidean_cols( + np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x, + double[:] means, + double[:] vars): cdef: - double [:] means = fit_params["means"] - double [:] vars = fit_params["vars"] - char normalize = fit_params["normalize"] - int n_rows, n_cols, col1, col2, row double val1, val2, d - double [:, :] distances n_rows, n_cols = x.shape[0], x.shape[1] - distances = np.zeros((n_cols, n_cols), dtype=float) with nogil: for col1 in range(n_cols): for col2 in range(col1): - d = 0 - for row in range(n_rows): - val1, val2 = x[row, col1], x[row, col2] - if normalize: - val1 = (val1 - means[col1]) / sqrt(2 * vars[col1]) - val2 = (val2 - means[col2]) / sqrt(2 * vars[col2]) + if npy_isnan(distances[col1, col2]): + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] if npy_isnan(val1): if npy_isnan(val2): - d += 1 + d += vars[col1] + vars[col2] \ + + (means[col1] - means[col2]) ** 2 else: - d += val2 ** 2 + 0.5 + d += (val2 - means[col1]) ** 2 + vars[col1] elif npy_isnan(val2): - d += val1 ** 2 + 0.5 + d += (val1 - means[col2]) ** 2 + vars[col2] else: d += (val1 - val2) ** 2 - else: + distances[col1, col2] = distances[col2, col1] = d + + +def fix_euclidean_cols_normalized( + np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x, + double[:] means, + double[:] vars): + cdef: + int n_rows, n_cols, col1, col2, row + double val1, val2, d + + n_rows, n_cols = x.shape[0], x.shape[1] + with nogil: + for col1 in range(n_cols): + for col2 in range(col1): + if npy_isnan(distances[col1, col2]): + d = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] if npy_isnan(val1): if npy_isnan(val2): - d += vars[col1] + vars[col2] \ - + (means[col1] - means[col2]) ** 2 + d += 1 else: - d += (val2 - means[col1]) ** 2 + vars[col1] + d += val2 ** 2 + 0.5 elif npy_isnan(val2): - d += (val1 - means[col2]) ** 2 + vars[col2] + d += val1 ** 2 + 0.5 else: d += (val1 - val2) ** 2 - distances[col1, col2] = distances[col2, col1] = d - return np.sqrt(distances) + distances[col1, col2] = distances[col2, col1] = d def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, From 50d7757759fc3118ab1b5ff06bf97bf54e51644c Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 20 Jul 2017 15:07:39 +0200 Subject: [PATCH 20/27] distances: Speed up all distances --- Orange/distance/__init__.py | 606 +- Orange/distance/_distance.c | 8228 +++++++++++------------- Orange/distance/_distance.pyx | 501 +- Orange/distance/distances.md | 8 +- Orange/distance/tests/calculation.xlsx | Bin 67107 -> 66297 bytes Orange/distance/tests/test_distance.py | 217 +- 6 files changed, 4436 insertions(+), 5124 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 7978ec2ab52..ab8702e0b5d 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -66,16 +66,16 @@ def _orange_to_numpy(x): class Distance: """ Base class for construction of distances models (:obj:`DistanceModel`). - + Distances can be computed between all pairs of rows in one table, or between pairs where one row is from one table and one from another. - + If `axis` is set to `0`, the class computes distances between all pairs of columns in a table. Distances between columns from separate tables are probably meaningless, thus unsupported. - + The class can be used as follows: - + - Constructor is called only with keyword argument `axis` that specifies the axis over which the distances are computed, and with other subclass-specific keyword arguments. @@ -86,12 +86,12 @@ class Distance: - We can then call the :obj:`DistanceModel` with data to compute the distance between its rows or columns, or with two data tables to compute distances between all pairs of rows. - + The second, shorter way to use this class is to call the constructor with one or two data tables and any additional keyword arguments. Constructor will execute the above steps and return :obj:`~Orange.misc.DistMatrix`. Such usage is here for backward compatibility, practicality and efficiency. - + Args: e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`): data on which to train the model and compute the distances @@ -101,14 +101,14 @@ class Distance: axis (int): axis over which the distances are computed, 1 (default) for rows, 0 for columns - + Attributes: axis (int): axis over which the distances are computed, 1 (default) for rows, 0 for columns impute (bool): if `True` (default is `False`), nans in the computed distances - are replaced with zeros, and infs with very large numbers. + are replaced with zeros, and infs with very large numbers. The capabilities of the metrics are described with class attributes. @@ -117,18 +117,18 @@ class Distance: attributes depends upon the type of distance; e.g. Jaccard distance observes whether the value is zero or non-zero, while Euclidean and Manhattan distance observes whether a pair of values is same or different. - + Class attribute `supports_missing` indicates that the distance can cope with missing data. In such cases, letting the distance handle it should be preferred over pre-imputation of missing values. - + Class attribute `supports_normalization` indicates that the constructor accepts an argument `normalize`. If set to `True`, the metric will attempt to normalize the values in a sense that each attribute will have equal influence. For instance, the Euclidean distance subtract the mean and divides the result by the deviation, while Manhattan distance uses the median and MAD. - + If class attribute `supports_sparse` is `True`, the class will handle sparse data. Currently, all classes that do handle it rely on fallbacks to SKL metrics. These, however, do not support discrete data and missing @@ -167,7 +167,7 @@ def fit(self, e1): """ Return a :obj:`DistanceModel` fit to the data. Must be implemented in subclasses. - + Args: e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`: @@ -177,21 +177,26 @@ def fit(self, e1): """ pass + @staticmethod + def check_no_discrete(n_vals): + if any(n_vals): + raise ValueError("columns with discrete values are incommensurable") + class DistanceModel: """ Base class for classes that compute distances between data rows or columns. Instances of these classes are not constructed directly but returned by the corresponding instances of :obj:`Distance`. - + Attributes: axis (int, readonly): axis over which the distances are computed, 1 (default) for rows, 0 for columns impute (bool): if `True` (default is `False`), nans in the computed distances - are replaced with zeros, and infs with very large numbers - + are replaced with zeros, and infs with very large numbers + """ def __init__(self, axis, impute=False): self._axis = axis @@ -206,7 +211,7 @@ def __call__(self, e1, e2=None): If e2 is omitted, calculate distances between all rows (axis=1) or columns (axis=2) of e1. If e2 is present, calculate distances between all pairs if rows from e1 and e2. - + This method converts the data into numpy arrays, calls the method `compute_data` and packs the result into `DistMatrix`. Subclasses are expected to define the `compute_data` and not the `__call__` method. @@ -216,7 +221,7 @@ def __call__(self, e1, e2=None): input data e2 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): secondary data - + Returns: A distance matrix (Orange.misc.distmatrix.DistMatrix) """ @@ -245,19 +250,25 @@ def compute_distances(self, x1, x2): call directly.""" pass + @staticmethod + def check_no_two_tables(x2): + if x2 is not None: + raise ValueError("columns of two tables cannot be compared") + class FittedDistanceModel(DistanceModel): """ Convenient common parent class for distance models with separate methods for fitting and for computation of distances across rows and columns. - + Results of fitting are packed into a dictionary for easier passing to Cython function that do the heavy lifting in these classes. - + Attributes: attributes (list of `Variable`): attributes on which the model was fit - fit_params (dict): data used by the model - + discrete (np.ndarray): bool array indicating discrete attributes + continuous (np.ndarray): bool array indicating continuous attributes + Class attributes: distance_by_cols: a function that accepts a numpy array and parameters and returns distances by columns. Usually a Cython function. @@ -266,34 +277,42 @@ class FittedDistanceModel(DistanceModel): a single array or between two arrays, and parameters; and returns distances by columns. Usually a Cython function. """ - def __init__(self, attributes, axis=1, impute=False, fit_params=None): + def __init__(self, attributes, axis=1, impute=False): super().__init__(axis, impute) self.attributes = attributes - self.fit_params = fit_params def __call__(self, e1, e2=None): - """ - Check the validity of the domains before passing the data to the - inherited method. - """ if e1.domain.attributes != self.attributes or \ - e2 is not None and e2.domain.attributes != self.attributes: + e2 is not None and e2.domain.attributes != self.attributes: raise ValueError("mismatching domains") return super().__call__(e1, e2) - def compute_distances(self, x1, x2=None): - """ - Compute distances by calling either `distance_by_cols` or - `distance_by_wors` - """ - if self.axis == 0: - return self.distance_by_cols(x1, self.fit_params) + def continuous_columns(self, x1, x2, offset, scale): + if self.continuous.all() and not self.normalize: + data1, data2 = x1, x2 else: - return self.distance_by_rows( - x1, - x2 if x2 is not None else x1, - x2 is not None, - self.fit_params) + data1 = x1[:, self.continuous] + if x2 is not None: + data2 = x2[:, self.continuous] + if self.normalize: + data1 = x1[:, self.continuous] + data1 -= offset + data1 /= scale + if x2 is not None: + data2 = x2[:, self.continuous] + data2 -= offset + data2 /= scale + if x2 is None: + data2 = data1 + return data1, data2 + + def discrete_columns(self, x1, x2): + if self.discrete.all(): + data1, data2 = x1, x1 if x2 is None else x2 + else: + data1 = x1[:, self.discrete] + data2 = data1 if x2 is None else x2[:, self.discrete] + return data1, data2 class FittedDistance(Distance): @@ -302,7 +321,7 @@ class FittedDistance(Distance): fitting and for computation of distances across rows and columns. Results of fitting are packed into a dictionary for easier passing to Cython function that do the heavy lifting in these classes. - + The class implements a method `fit` that calls either `fit_columns` or `fit_rows` with the data and the number of values for discrete attributes. @@ -310,7 +329,7 @@ class FittedDistance(Distance): Class attribute `ModelType` contains the type of the model returned by `fit`. """ - ModelType = None #: Option[FittedDistanceModel] + rows_model_type = None #: Option[FittedDistanceModel] def fit(self, data): attributes = data.domain.attributes @@ -319,15 +338,73 @@ def fit(self, data): (len(attr.values) if attr.is_discrete else 0 for attr in attributes), dtype=np.int32, count=len(attributes)) - fit_params = [self.fit_cols, self.fit_rows][self.axis](x, n_vals) - # pylint: disable=not-callable - return self.ModelType(attributes, axis=self.axis, fit_params=fit_params) + return [self.fit_cols, self.fit_rows][self.axis](attributes, x, n_vals) - def fit_cols(self, x, n_vals): - if any(n_vals): - raise ValueError("columns with discrete values are incommensurable") + def fit_rows(self, attributes, x, n_vals): + """ + Compute statistics needed for normalization and for handling + missing data for row distances. Returns a dictionary with the + following keys: - def fit_rows(self, x, n_vals): + - means: a means of numeric columns; undefined for discrete + - vars: variances of numeric columns, -1 for discrete, -2 to ignore + - dist_missing: a 2d-array; dist_missing[col, value] is the distance + added for the given `value` in discrete column `col` if the value + for the other row is missing; undefined for numeric columns + - dist_missing2: the value used for distance if both values are missing; + used for discrete and numeric columns + - normalize: set to `self.normalize`, so it is passed to the Cython + function + + A column is marked to be ignored if all its values are nan or if + `self.normalize` is `True` and the variance of the column is 0. + """ + n_cols = len(n_vals) + + discrete = n_vals > 0 + n_bins = max(n_vals, default=0) + n_discrete = sum(discrete) + dist_missing_disc = np.zeros((n_discrete, n_bins), dtype=float) + dist_missing2_disc = np.zeros(n_discrete, dtype=float) + + continuous = ~discrete + n_continuous = sum(continuous) + offsets = np.zeros(n_continuous, dtype=float) + scales = np.empty(n_continuous, dtype=float) + dist_missing2_cont = np.zeros(n_continuous, dtype=float) + + curr_disc = curr_cont = 0 + for col in range(n_cols): + column = x[:, col] + if np.isnan(column).all(): + continuous[col] = discrete[col] = False + elif discrete[col]: + discrete_stats = self.get_discrete_stats(column, n_bins) + if discrete_stats is not None: + dist_missing_disc[curr_disc], \ + dist_missing2_disc[curr_disc] = discrete_stats + curr_disc += 1 + else: + continuous_stats = self.get_continuous_stats(column) + if continuous_stats is not None: + offsets[curr_cont], scales[curr_cont],\ + dist_missing2_cont[curr_cont] = continuous_stats + curr_cont += 1 + else: + continuous[col] = False + return self.rows_model_type( + attributes, impute, getattr(self, "normalize", False), + continuous, discrete, + offsets[:curr_cont], scales[:curr_cont], + dist_missing2_cont[:curr_cont], + dist_missing_disc, dist_missing2_disc) + + def get_discrete_stats(self, column, n_bins): + dist = util.bincount(column, minlength=n_bins)[0] + dist /= max(1, sum(dist)) + return 1 - dist, 1 - np.sum(dist ** 2) + + def get_continuous_stats(self, column): pass @@ -362,35 +439,29 @@ def __call__(self, e1, e2=None, axis=1, impute=False): return dist_matrix -class EuclideanModel(FittedDistanceModel): - def distance_by_rows(self, x1, x2, two_tables, fit_params): - vars = fit_params["vars"] - means = fit_params["means"] - dist_missing = fit_params["dist_missing"] - dist_missing2 = fit_params["dist_missing2"] - normalize = fit_params["normalize"] - - cols = vars >= 0 - if np.any(cols): - if normalize: - data1 = x1[:, cols] - data1 -= means[cols] - data1 /= np.sqrt(2 * vars[cols]) - if two_tables: - data2 = x2[:, cols] - data2 -= means - data2 /= np.sqrt(2 * vars[cols]) - else: - data2 = data1 - elif np.all(cols): - data1, data2 = x1, x2 - else: - data1 = x1[:, cols] - data2 = x2[:, cols] if two_tables else data1 +class EuclideanRowsModel(FittedDistanceModel): + def __init__(self, attributes, impute, normalize, + continuous, discrete, + means, vars, dist_missing2_cont, + dist_missing_disc, dist_missing2_disc): + super().__init__(attributes, 1, impute) + self.normalize = normalize + self.continuous = continuous + self.discrete = discrete + self.means = means + self.vars = vars + self.dist_missing2_cont = dist_missing2_cont + self.dist_missing_disc = dist_missing_disc + self.dist_missing2_disc = dist_missing2_disc + + def compute_distances(self, x1, x2=None): + if self.continuous.any(): + data1, data2 = self.continuous_columns( + x1, x2, self.means, np.sqrt(2 * self.vars)) # adapted from sklearn.metric.euclidean_distances xx = row_norms(data1, squared=True)[:, np.newaxis] - if two_tables: + if x2 is not None: yy = row_norms(data2, squared=True)[np.newaxis, :] else: yy = xx.T @@ -399,36 +470,38 @@ def distance_by_rows(self, x1, x2, two_tables, fit_params): distances += xx distances += yy np.maximum(distances, 0, out=distances) - if not two_tables: + if x2 is None: distances.flat[::distances.shape[0] + 1] = 0.0 - - if normalize: - _distance.fix_euclidean_rows_normalized(distances, data1, data2, means[cols], vars[cols], dist_missing2[cols], two_tables) - else: - _distance.fix_euclidean_rows(distances, data1, data2, means[cols], vars[cols], dist_missing2[cols], two_tables) - + fixer = [_distance.fix_euclidean_rows, + _distance.fix_euclidean_rows_normalized][self.normalize] + fixer(distances, data1, data2, + self.means, self.vars, self.dist_missing2_cont, + x2 is not None) else: - distances = np.zeros((x1.shape[0], x2.shape[0])) + distances = np.zeros((x1.shape[0], + (x2 if x2 is not None else x1).shape[0])) - cols = vars == -1 - if np.any(cols): - if np.all(cols): - data1, data2 = x1, x2 - else: - data1 = x1[:, cols] - data2 = x2[:, cols] if two_tables else data1 - _distance.euclidean_rows_discrete(distances, data1, data2, dist_missing[cols], dist_missing2[cols], two_tables) + if np.any(self.discrete): + data1, data2 = self.discrete_columns(x1, x2) + _distance.euclidean_rows_discrete( + distances, data1, data2, self.dist_missing_disc, + self.dist_missing2_disc, x2 is not None) return np.sqrt(distances) - def distance_by_cols(self, x1, fit_params): - vars = fit_params["vars"] - means = fit_params["means"] - normalize = fit_params["normalize"] - if normalize: - x1 = x1 - means - x1 /= np.sqrt(2 * vars) +class EuclideanColumnsModel(FittedDistanceModel): + def __init__(self, attributes, impute, normalize, means, vars): + super().__init__(attributes, 0, impute) + self.normalize = normalize + self.means = means + self.vars = vars + + def compute_distances(self, x1, x2=None): + self.check_no_two_tables(x2) + if self.normalize: + x1 = x1 - self.means + x1 /= np.sqrt(2 * self.vars) # adapted from sklearn.metric.euclidean_distances xx = row_norms(x1.T, squared=True)[:, np.newaxis] @@ -439,10 +512,9 @@ def distance_by_cols(self, x1, fit_params): np.maximum(distances, 0, out=distances) distances.flat[::distances.shape[0] + 1] = 0.0 - if normalize: - _distance.fix_euclidean_cols_normalized(distances, x1, means, vars) - else: - _distance.fix_euclidean_cols(distances, x1, means, vars) + fixer = [_distance.fix_euclidean_cols, + _distance.fix_euclidean_cols_normalized][self.normalize] + fixer(distances, x1, self.means, self.vars) return np.sqrt(distances) @@ -451,65 +523,25 @@ class Euclidean(FittedDistance): supports_discrete = True supports_normalization = True fallback = SklDistance('euclidean') - ModelType = EuclideanModel + rows_model_type = EuclideanRowsModel def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) - def fit_rows(self, x, n_vals): - """ - Compute statistics needed for normalization and for handling - missing data for row distances. Returns a dictionary with the - following keys: - - - means: a means of numeric columns; undefined for discrete - - vars: variances of numeric columns, -1 for discrete, -2 to ignore - - dist_missing: a 2d-array; dist_missing[col, value] is the distance - added for the given `value` in discrete column `col` if the value - for the other row is missing; undefined for numeric columns - - dist_missing2: the value used for distance if both values are missing; - used for discrete and numeric columns - - normalize: set to `self.normalize`, so it is passed to the Cython - function - - A column is marked to be ignored if all its values are nan or if - `self.normalize` is `True` and the variance of the column is 0. - """ - super().fit_rows(x, n_vals) - n_cols = len(n_vals) - n_bins = max(n_vals) - means = np.zeros(n_cols, dtype=float) - vars = np.empty(n_cols, dtype=float) - dist_missing = np.zeros((n_cols, n_bins), dtype=float) - dist_missing2 = np.zeros(n_cols, dtype=float) - - for col in range(n_cols): - column = x[:, col] - if n_vals[col]: - vars[col] = -1 - dist_missing[col] = util.bincount(column, minlength=n_bins)[0] - dist_missing[col] /= max(1, sum(dist_missing[col])) - dist_missing2[col] = 1 - np.sum(dist_missing[col] ** 2) - dist_missing[col] = 1 - dist_missing[col] - elif np.isnan(column).all(): # avoid warnings in nanmean and nanvar - vars[col] = -2 - else: - means[col] = util.nanmean(column) - vars[col] = util.nanvar(column) - if self.normalize: - dist_missing2[col] = 1 - if vars[col] == 0: - vars[col] = -2 - else: - dist_missing2[col] = 2 * vars[col] - if np.isnan(dist_missing2[col]): - dist_missing2[col] = 0 - - return dict(means=means, vars=vars, - dist_missing=dist_missing, dist_missing2=dist_missing2, - normalize=int(self.normalize)) + def get_continuous_stats(self, column): + mean = util.nanmean(column) + var = util.nanvar(column) + if self.normalize: + if var == 0: + return None + dist_missing2_cont = 1 + else: + dist_missing2_cont = 2 * var + if np.isnan(dist_missing2_cont): + dist_missing2_cont = 0 + return mean, var, dist_missing2_cont - def fit_cols(self, x, n_vals): + def fit_cols(self, attributes, x, n_vals): """ Compute statistics needed for normalization and for handling missing data for columns. Returns a dictionary with the @@ -520,17 +552,74 @@ def fit_cols(self, x, n_vals): - normalize: set to self.normalize, so it is passed to the Cython function """ - super().fit_cols(x, n_vals) + self.check_no_discrete(n_vals) means = np.nanmean(x, axis=0) vars = np.nanvar(x, axis=0) if self.normalize and (np.isnan(vars).any() or not vars.all()): raise ValueError("some columns are constant or have no values") - return dict(means=means, vars=vars, normalize=int(self.normalize)) + return EuclideanColumnsModel( + attributes, self.impute, self.normalize, means, vars) + + +class ManhattanRowsModel(FittedDistanceModel): + def __init__(self, attributes, impute, normalize, + continuous, discrete, + medians, mads, dist_missing2_cont, + dist_missing_disc, dist_missing2_disc): + super().__init__(attributes, 1, impute) + self.normalize = normalize + self.continuous = continuous + self.discrete = discrete + self.medians = medians + self.mads = mads + self.dist_missing2_cont = dist_missing2_cont + self.dist_missing_disc = dist_missing_disc + self.dist_missing2_disc = dist_missing2_disc + def compute_distances(self, x1, x2): + if self.continuous.any(): + data1, data2 = self.continuous_columns( + x1, x2, self.medians, 2 * self.mads) + distances = _distance.manhattan_rows_cont( + data1, data2, x2 is not None) + if self.normalize: + _distance.fix_manhattan_rows_normalized( + distances, data1, data2, x2 is not None) + else: + _distance.fix_manhattan_rows( + distances, data1, data2, + self.medians, self.mads, self.dist_missing2_cont, + x2 is not None) + else: + distances = np.zeros((x1.shape[0], + (x2 if x2 is not None else x1).shape[0])) -class ManhattanModel(FittedDistanceModel): + if np.any(self.discrete): + data1, data2 = self.discrete_columns(x1, x2) + # For discrete attributes, Euclidean is same as Manhattan + _distance.euclidean_rows_discrete( + distances, data1, data2, self.dist_missing_disc, + self.dist_missing2_disc, x2 is not None) + + return distances + + +class ManhattanColumnsModel(FittedDistanceModel): distance_by_cols = _distance.manhattan_cols - distance_by_rows = _distance.manhattan_rows + + def __init__(self, attributes, impute, normalize, medians, mads): + super().__init__(attributes, 0, impute) + self.normalize = normalize + self.medians = medians + self.mads = mads + + def compute_distances(self, x1, x2=None): + self.check_no_two_tables(x2) + if self.normalize: + x1 = x1 - self.medians + x1 /= 2 + x1 /= self.mads + return _distance.manhattan_cols(x1, self.medians, self.mads, self.normalize) class Manhattan(FittedDistance): @@ -538,63 +627,25 @@ class Manhattan(FittedDistance): supports_discrete = True supports_normalization = True fallback = SklDistance('manhattan') - ModelType = ManhattanModel + rows_model_type = ManhattanRowsModel def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) - def fit_rows(self, x, n_vals): - """ - Compute statistics needed for normalization and for handling - missing data for row distances. Returns a dictionary with the - following keys: - - - medians: medians of numeric columns; undefined for discrete - - mads: medians of absolute distances from the median for numeric - columns, -1 for discrete, -2 to ignore - - dist_missing: a 2d-array; dist_missing[col, value] is the distance - added for the given `value` in discrete column `col` if the value - for the other row is missing; undefined for numeric columns - - dist_missing2: the value used for distance if both values are missing; - used for discrete and numeric columns - - normalize: set to `self.normalize`, so it is passed to the Cython - function - - A column is marked to be ignored if all its values are nan or if - `self.normalize` is `True` and the median of the column is 0. - """ - super().fit_rows(x, n_vals) - n_cols = len(n_vals) - n_bins = max(n_vals) - - medians = np.zeros(n_cols) - mads = np.zeros(n_cols) - dist_missing = np.zeros((n_cols, max(n_vals))) - dist_missing2 = np.zeros(n_cols) - for col in range(n_cols): - column = x[:, col] - if n_vals[col]: - mads[col] = -1 - dist_missing[col] = util.bincount(column, minlength=n_bins)[0] - dist_missing[col] /= max(1, sum(dist_missing[col])) - dist_missing2[col] = 1 - np.sum(dist_missing[col] ** 2) - dist_missing[col] = 1 - dist_missing[col] - elif np.isnan(column).all(): # avoid warnings in nanmedian - mads[col] = -2 - else: - medians[col] = np.nanmedian(column) - mads[col] = np.nanmedian(np.abs(column - medians[col])) - if self.normalize: - dist_missing2[col] = 1 - if mads[col] == 0: - mads[col] = -2 - else: - dist_missing2[col] = 2 * mads[col] - return dict(medians=medians, mads=mads, - dist_missing=dist_missing, dist_missing2=dist_missing2, - normalize=int(self.normalize)) + def get_continuous_stats(self, column): + median = np.nanmedian(column) + mad = np.nanmedian(np.abs(column - median)) + if self.normalize: + if mad == 0: + return None + dist_missing2_cont = 1 + else: + dist_missing2_cont = 2 * mad + if np.isnan(dist_missing2_cont): + dist_missing2_cont = 0 + return median, mad, dist_missing2_cont - def fit_cols(self, x, n_vals): + def fit_cols(self, attributes, x, n_vals): """ Compute statistics needed for normalization and for handling missing data for columns. Returns a dictionary with the @@ -605,74 +656,95 @@ def fit_cols(self, x, n_vals): - normalize: set to self.normalize, so it is passed to the Cython function """ - super().fit_cols(x, n_vals) + self.check_no_discrete(n_vals) medians = np.nanmedian(x, axis=0) mads = np.nanmedian(np.abs(x - medians), axis=0) if self.normalize and (np.isnan(mads).any() or not mads.all()): raise ValueError( "some columns have zero absolute distance from median, " "or no values") - return dict(medians=medians, mads=mads, normalize=int(self.normalize)) - - -class CosineModel(FittedDistanceModel): - distance_by_rows = _distance.cosine_rows - distance_by_cols = _distance.cosine_cols + return ManhattanColumnsModel( + attributes, self.impute, self.normalize, medians, mads) class Cosine(FittedDistance): supports_sparse = True # via fallback supports_discrete = True fallback = SklDistance('cosine') - ModelType = CosineModel - def fit_rows(self, x, n_vals): - """ - Compute statistics needed for normalization and for handling - missing data for row and column based distances. Although the - computation is asymmetric, the same statistics are needed in both cases. - - Returns a dictionary with the following keys: + @staticmethod + def discrete_to_indicators(x, discrete): + if discrete.any(): + x = x.copy() + for col, disc in enumerate(discrete): + if disc: + x[:, col].clip(0, 1, out=x[:, col]) + return x + + def fit_rows(self, attributes, x, n_vals): + discrete = n_vals > 0 + x = self.discrete_to_indicators(x, discrete) + means = util.nanmean(x, axis=0) + np.nan_to_num(means, copy=False) + return self.CosineModel(attributes, self.axis, self.impute, + discrete, means) - - means: means of numeric columns; relative frequencies of non-zero - values for discrete - - vars: variances of numeric columns, -1 for discrete, -2 to ignore - - dist_missing2: the value used for distance if both values are missing; - used for discrete and numeric columns - - A column is marked to be ignored if all its values are nan. - """ - super().fit_rows(x, n_vals) - n, n_cols = x.shape - means = np.zeros(n_cols, dtype=float) - vars = np.empty(n_cols, dtype=float) - dist_missing2 = np.zeros(n_cols, dtype=float) - - for col in range(n_cols): - column = x[:, col] - if n_vals[col]: - vars[col] = -1 - nonnans = n - np.sum(np.isnan(column)) - means[col] = 1 - np.sum(column == 0) / nonnans - dist_missing2[col] = means[col] - elif np.isnan(column).all(): # avoid warnings in nanmean and nanvar - vars[col] = -2 - else: - means[col] = util.nanmean(column) - vars[col] = util.nanvar(column) - dist_missing2[col] = means[col] ** 2 - if np.isnan(dist_missing2[col]): - dist_missing2[col] = 0 + fit_cols = fit_rows - return dict(means=means, vars=vars, dist_missing2=dist_missing2) + class CosineModel(FittedDistanceModel): + def __init__(self, attributes, axis, impute, discrete, means): + super().__init__(attributes, axis, impute) + self.discrete = discrete + self.means = means - fit_cols = fit_rows + def compute_distances(self, x1, x2): + def prepare_data(x): + if self.discrete.any(): + data = Cosine.discrete_to_indicators(x, self.discrete) + else: + data = x.copy() + for col, mean in enumerate(self.means): + column = data[:, col] + column[np.isnan(column)] = mean + if self.axis == 0: + data = data.T + data /= row_norms(data)[:, np.newaxis] + return data + + data1 = prepare_data(x1) + data2 = data1 if x2 is None else prepare_data(x2) + dist = safe_sparse_dot(data1, data2.T) + np.clip(dist, 0, 1, out=dist) + if x2 is None: + dist.flat[::dist.shape[0] + 1] = 1.0 + return 1 - dist class JaccardModel(FittedDistanceModel): - distance_by_cols = _distance.jaccard_cols - distance_by_rows = _distance.jaccard_rows + def __init__(self, attributes, axis, impute, ps): + super().__init__(attributes, axis, impute) + self.ps = ps + def compute_distances(self, x1, x2): + nonzeros1 = np.not_equal(x1, 0).view(np.int8) + if self.axis == 1: + nans1 = _distance.any_nan_row(x1) + if x2 is None: + nonzeros2, nans2 = nonzeros1, nans1 + else: + nonzeros2 = np.not_equal(x2, 0).view(np.int8) + nans2 = _distance.any_nan_row(x2) + return _distance.jaccard_rows( + nonzeros1, nonzeros2, + x1, x1 if x2 is None else x2, + nans1, nans2, + self.ps, + x2 is not None) + else: + nans1 = _distance.any_nan_row(x1.T) + self.check_no_two_tables(x2) + return _distance.jaccard_cols( + nonzeros1, x1, nans1, self.ps) class Jaccard(FittedDistance): supports_sparse = False @@ -680,7 +752,7 @@ class Jaccard(FittedDistance): fallback = SklDistance('jaccard') ModelType = JaccardModel - def fit_rows(self, x, n_vals): + def fit_rows(self, attributes, x, n_vals): """ Compute statistics needed for normalization and for handling missing data for row and column based distances. Although the @@ -688,13 +760,13 @@ def fit_rows(self, x, n_vals): Returns a dictionary with the following key: - - ps: relative freuenceies of non-zero values + - ps: relative frequencies of non-zero values """ - return { - "ps": np.fromiter( - (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), - dtype=np.double, count=len(n_vals))} + ps = np.fromiter( + (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), + dtype=np.double, count=len(n_vals)) + return JaccardModel(attributes, self.axis, self.impute, ps) fit_cols = fit_rows @@ -808,7 +880,7 @@ def compute_distances(self, x1, x2): class MahalanobisDistance: """ Obsolete class needed for backward compatibility. - + Previous implementation of instances did not have a separate fitting phase, except for MahalanobisDistance, which was implemented in a single class but required first (explicitly) calling the method 'fit'. The backward diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index 84b6b1d69d5..e2db68fe3a5 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -1163,14 +1163,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); @@ -1370,6 +1362,14 @@ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); @@ -1458,6 +1458,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp); static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj); +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); + /* None.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus @@ -1657,8 +1660,6 @@ static PyObject *indirect_contiguous = 0; static int __pyx_memoryview_thread_locks_used; static PyThread_type_lock __pyx_memoryview_thread_locks[8]; static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice); /*proto*/ -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); /*proto*/ -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); /*proto*/ static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ static void *__pyx_align_pointer(void *, size_t); /*proto*/ static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ @@ -1692,6 +1693,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/ static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t = { "int8_t", NULL, sizeof(__pyx_t_5numpy_int8_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int8_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int8_t), 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "Orange.distance._distance" int __pyx_module_is_main_Orange__distance___distance = 0; @@ -1719,16 +1721,15 @@ static const char __pyx_k_col[] = "col"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_row[] = "row"; static const char __pyx_k_val[] = "val"; -static const char __pyx_k_abs1[] = "abs1"; -static const char __pyx_k_abs2[] = "abs2"; -static const char __pyx_k_abss[] = "abss"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_col1[] = "col1"; static const char __pyx_k_col2[] = "col2"; +static const char __pyx_k_int8[] = "int8"; static const char __pyx_k_mads[] = "mads"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mode[] = "mode"; static const char __pyx_k_name[] = "name"; +static const char __pyx_k_nans[] = "nans"; static const char __pyx_k_ndim[] = "ndim"; static const char __pyx_k_pack[] = "pack"; static const char __pyx_k_row1[] = "row1"; @@ -1743,12 +1744,13 @@ static const char __pyx_k_vars[] = "vars"; static const char __pyx_k_ASCII[] = "ASCII"; static const char __pyx_k_class[] = "__class__"; static const char __pyx_k_dtype[] = "dtype"; -static const char __pyx_k_empty[] = "empty"; static const char __pyx_k_error[] = "error"; static const char __pyx_k_flags[] = "flags"; static const char __pyx_k_ival1[] = "ival1"; static const char __pyx_k_ival2[] = "ival2"; static const char __pyx_k_means[] = "means"; +static const char __pyx_k_nans1[] = "nans1"; +static const char __pyx_k_nans2[] = "nans2"; static const char __pyx_k_numpy[] = "numpy"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_shape[] = "shape"; @@ -1758,7 +1760,7 @@ static const char __pyx_k_zeros[] = "zeros"; static const char __pyx_k_encode[] = "encode"; static const char __pyx_k_format[] = "format"; static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_in_one[] = "in_one"; +static const char __pyx_k_in_any[] = "in_any"; static const char __pyx_k_n_cols[] = "n_cols"; static const char __pyx_k_n_rows[] = "n_rows"; static const char __pyx_k_name_2[] = "__name__"; @@ -1779,6 +1781,8 @@ static const char __pyx_k_unk1_in2[] = "unk1_in2"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_distances[] = "distances"; static const char __pyx_k_enumerate[] = "enumerate"; +static const char __pyx_k_nonzeros1[] = "nonzeros1"; +static const char __pyx_k_nonzeros2[] = "nonzeros2"; static const char __pyx_k_normalize[] = "normalize"; static const char __pyx_k_not1_unk2[] = "not1_unk2"; static const char __pyx_k_p_nonzero[] = "p_nonzero"; @@ -1786,12 +1790,10 @@ static const char __pyx_k_unk1_not2[] = "unk1_not2"; static const char __pyx_k_unk1_unk2[] = "unk1_unk2"; static const char __pyx_k_IndexError[] = "IndexError"; static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_fit_params[] = "fit_params"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_two_tables[] = "two_tables"; static const char __pyx_k_MemoryError[] = "MemoryError"; -static const char __pyx_k_cosine_cols[] = "cosine_cols"; -static const char __pyx_k_cosine_rows[] = "cosine_rows"; +static const char __pyx_k_any_nan_row[] = "any_nan_row"; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_dist_missing[] = "dist_missing"; static const char __pyx_k_intersection[] = "intersection"; @@ -1800,12 +1802,14 @@ static const char __pyx_k_jaccard_rows[] = "jaccard_rows"; static const char __pyx_k_dist_missing2[] = "dist_missing2"; static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; static const char __pyx_k_manhattan_cols[] = "manhattan_cols"; -static const char __pyx_k_manhattan_rows[] = "manhattan_rows"; static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; +static const char __pyx_k_dist_missing2_cont[] = "dist_missing2_cont"; static const char __pyx_k_fix_euclidean_cols[] = "fix_euclidean_cols"; static const char __pyx_k_fix_euclidean_rows[] = "fix_euclidean_rows"; +static const char __pyx_k_fix_manhattan_rows[] = "fix_manhattan_rows"; static const char __pyx_k_strided_and_direct[] = ""; +static const char __pyx_k_manhattan_rows_cont[] = "manhattan_rows_cont"; static const char __pyx_k_strided_and_indirect[] = ""; static const char __pyx_k_contiguous_and_direct[] = ""; static const char __pyx_k_MemoryView_of_r_object[] = ""; @@ -1819,6 +1823,7 @@ static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cyt static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static const char __pyx_k_fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized"; static const char __pyx_k_fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized"; +static const char __pyx_k_fix_manhattan_rows_normalized[] = "fix_manhattan_rows_normalized"; static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static const char __pyx_k_strided_and_direct_or_indirect[] = ""; static const char __pyx_k_Users_janez_Dropbox_orange3_Ora[] = "/Users/janez/Dropbox/orange3/Orange/distance/_distance.pyx"; @@ -1860,10 +1865,8 @@ static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; static PyObject *__pyx_kp_s_Users_janez_Dropbox_orange3_Ora; static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_n_s_abs1; -static PyObject *__pyx_n_s_abs2; -static PyObject *__pyx_n_s_abss; static PyObject *__pyx_n_s_allocate_buffer; +static PyObject *__pyx_n_s_any_nan_row; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_c; static PyObject *__pyx_n_u_c; @@ -1873,24 +1876,23 @@ static PyObject *__pyx_n_s_col1; static PyObject *__pyx_n_s_col2; static PyObject *__pyx_kp_s_contiguous_and_direct; static PyObject *__pyx_kp_s_contiguous_and_indirect; -static PyObject *__pyx_n_s_cosine_cols; -static PyObject *__pyx_n_s_cosine_rows; static PyObject *__pyx_n_s_d; static PyObject *__pyx_n_s_dist_missing; static PyObject *__pyx_n_s_dist_missing2; +static PyObject *__pyx_n_s_dist_missing2_cont; static PyObject *__pyx_n_s_distances; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dtype_is_object; -static PyObject *__pyx_n_s_empty; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_euclidean_rows_discrete; -static PyObject *__pyx_n_s_fit_params; static PyObject *__pyx_n_s_fix_euclidean_cols; static PyObject *__pyx_n_s_fix_euclidean_cols_normalized; static PyObject *__pyx_n_s_fix_euclidean_rows; static PyObject *__pyx_n_s_fix_euclidean_rows_normalized; +static PyObject *__pyx_n_s_fix_manhattan_rows; +static PyObject *__pyx_n_s_fix_manhattan_rows_normalized; static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_fortran; @@ -1899,8 +1901,9 @@ static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_in1_unk2; +static PyObject *__pyx_n_s_in_any; static PyObject *__pyx_n_s_in_both; -static PyObject *__pyx_n_s_in_one; +static PyObject *__pyx_n_s_int8; static PyObject *__pyx_n_s_intersection; static PyObject *__pyx_n_s_itemsize; static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; @@ -1911,7 +1914,7 @@ static PyObject *__pyx_n_s_jaccard_rows; static PyObject *__pyx_n_s_mads; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_manhattan_cols; -static PyObject *__pyx_n_s_manhattan_rows; +static PyObject *__pyx_n_s_manhattan_rows_cont; static PyObject *__pyx_n_s_means; static PyObject *__pyx_n_s_medians; static PyObject *__pyx_n_s_memview; @@ -1922,11 +1925,16 @@ static PyObject *__pyx_n_s_n_rows1; static PyObject *__pyx_n_s_n_rows2; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_name_2; +static PyObject *__pyx_n_s_nans; +static PyObject *__pyx_n_s_nans1; +static PyObject *__pyx_n_s_nans2; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_ndim; static PyObject *__pyx_n_s_nonnans; static PyObject *__pyx_n_s_nonzeros; +static PyObject *__pyx_n_s_nonzeros1; +static PyObject *__pyx_n_s_nonzeros2; static PyObject *__pyx_n_s_normalize; static PyObject *__pyx_n_s_not1_unk2; static PyObject *__pyx_n_s_np; @@ -1973,13 +1981,14 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars); /* proto */ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_18cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ @@ -2018,12 +2027,11 @@ static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_float_1_0; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_slice_; -static PyObject *__pyx_slice__2; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; @@ -2031,18 +2039,17 @@ static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__16; +static PyObject *__pyx_slice__17; static PyObject *__pyx_slice__18; -static PyObject *__pyx_slice__19; -static PyObject *__pyx_slice__20; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__16; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__21; +static PyObject *__pyx_tuple__19; +static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__26; @@ -2060,6 +2067,7 @@ static PyObject *__pyx_tuple__47; static PyObject *__pyx_tuple__48; static PyObject *__pyx_tuple__49; static PyObject *__pyx_tuple__50; +static PyObject *__pyx_codeobj__21; static PyObject *__pyx_codeobj__23; static PyObject *__pyx_codeobj__25; static PyObject *__pyx_codeobj__27; @@ -4658,31 +4666,29 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma /* "Orange/distance/_distance.pyx":188 * * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables): */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows[] = "manhattan_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows = {"manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows_cont[] = "manhattan_rows_cont(ndarray x1, ndarray x2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows_cont = {"manhattan_rows_cont", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows_cont}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("manhattan_rows (wrapper)", 0); + __Pyx_RefNannySetupContext("manhattan_rows_cont (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; - PyObject* values[4] = {0,0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,0}; + PyObject* values[3] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -4697,46 +4703,39 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 1); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 1); __PYX_ERR(0, 188, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 2); __PYX_ERR(0, 188, __pyx_L3_error) - } - case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, 3); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 2); __PYX_ERR(0, 188, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows") < 0)) __PYX_ERR(0, 188, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows_cont") < 0)) __PYX_ERR(0, 188, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { 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); } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) - __pyx_v_fit_params = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows_cont", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 188, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 189, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -4747,76 +4746,52 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; int __pyx_v_row1; int __pyx_v_row2; int __pyx_v_col; - double __pyx_v_val1; - double __pyx_v_val2; double __pyx_v_d; - int __pyx_v_ival1; - int __pyx_v_ival2; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyArrayObject *__pyx_v_distances = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_4; - npy_intp __pyx_t_5; - npy_intp __pyx_t_6; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - Py_ssize_t __pyx_t_10; - Py_ssize_t __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; int __pyx_t_15; int __pyx_t_16; - int __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; + Py_ssize_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; - __pyx_t_5numpy_float64_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - __pyx_t_5numpy_float64_t __pyx_t_27; - int __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - Py_ssize_t __pyx_t_39; - Py_ssize_t __pyx_t_40; - Py_ssize_t __pyx_t_41; - Py_ssize_t __pyx_t_42; - Py_ssize_t __pyx_t_43; - Py_ssize_t __pyx_t_44; - Py_ssize_t __pyx_t_45; - __Pyx_RefNannySetupContext("manhattan_rows", 0); + int __pyx_t_23; + __Pyx_memviewslice __pyx_t_24 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_RefNannySetupContext("manhattan_rows_cont", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -4836,211 +4811,88 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_U } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":193 - * fit_params): - * cdef: - * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_medians = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":194 - * cdef: - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_mads = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":195 - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] # <<<<<<<<<<<<<< - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; - /* "Orange/distance/_distance.pyx":196 - * double [:] mads = fit_params["mads"] - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":197 - * double [:, :] dist_missing = fit_params["dist_missing"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_4; - - /* "Orange/distance/_distance.pyx":204 - * double [:, :] distances + * np.ndarray[np.float64_t, ndim=2] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_5 = (__pyx_v_x1->dimensions[0]); - __pyx_t_6 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_5; - __pyx_v_n_cols = __pyx_t_6; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":205 + /* "Orange/distance/_distance.pyx":197 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ - * == len(dist_missing) == len(dist_missing2) - */ - __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - - /* "Orange/distance/_distance.pyx":206 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_7 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mads, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 206, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_8); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_medians, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 206, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_8 == __pyx_t_9); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":207 - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ - * == len(dist_missing) == len(dist_missing2) # <<<<<<<<<<<<<< - * * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_9 == __pyx_t_10); - if (__pyx_t_7) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = (__pyx_t_10 == __pyx_t_11); - } - } - } - } + __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":206 + /* "Orange/distance/_distance.pyx":198 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(mads) == len(medians) \ # <<<<<<<<<<<<<< - * == len(dist_missing) == len(dist_missing2) - * - */ - if (unlikely(!(__pyx_t_7 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 206, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":209 - * == len(dist_missing) == len(dist_missing2) - * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); - __pyx_t_1 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 209, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_3; - __pyx_t_3.memview = NULL; - __pyx_t_3.data = NULL; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_7 = ((PyArrayObject *)__pyx_t_3); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11); + } + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) + } + __pyx_t_7 = 0; + __pyx_v_distances = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; - /* "Orange/distance/_distance.pyx":210 - * + /* "Orange/distance/_distance.pyx":199 + * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): @@ -5053,18 +4905,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_U #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":200 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): * d = 0 */ - __pyx_t_15 = __pyx_v_n_rows1; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_row1 = __pyx_t_16; + __pyx_t_8 = __pyx_v_n_rows1; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_8; __pyx_t_12+=1) { + __pyx_v_row1 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":212 + /* "Orange/distance/_distance.pyx":201 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -5072,551 +4924,194 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows(CYTHON_U * for col in range(n_cols): */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_17 = __pyx_v_n_rows2; + __pyx_t_13 = __pyx_v_n_rows2; } else { - __pyx_t_17 = __pyx_v_row1; + __pyx_t_13 = __pyx_v_row1; } - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { - __pyx_v_row2 = __pyx_t_18; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_v_row2 = __pyx_t_14; - /* "Orange/distance/_distance.pyx":213 + /* "Orange/distance/_distance.pyx":202 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< * for col in range(n_cols): - * if mads[col] == -2: + * d += fabs(x1[row1, col] - x2[row2, col]) */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":214 + /* "Orange/distance/_distance.pyx":203 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< - * if mads[col] == -2: - * continue + * d += fabs(x1[row1, col] - x2[row2, col]) + * distances[row1, row2] = d */ - __pyx_t_19 = __pyx_v_n_cols; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col = __pyx_t_20; + __pyx_t_15 = __pyx_v_n_cols; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_col = __pyx_t_16; - /* "Orange/distance/_distance.pyx":215 + /* "Orange/distance/_distance.pyx":204 * d = 0 * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue - * + * d += fabs(x1[row1, col] - x2[row2, col]) # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * # TODO: Do this only at the end, not after each function */ - __pyx_t_21 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_21 * __pyx_v_mads.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_7) { + __pyx_t_17 = __pyx_v_row1; + __pyx_t_18 = __pyx_v_col; + __pyx_t_19 = __pyx_v_row2; + __pyx_t_20 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + fabs(((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_x1.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides))))); + } - /* "Orange/distance/_distance.pyx":216 + /* "Orange/distance/_distance.pyx":205 * for col in range(n_cols): - * if mads[col] == -2: - * continue # <<<<<<<<<<<<<< - * - * val1, val2 = x1[row1, col], x2[row2, col] + * d += fabs(x1[row1, col] - x2[row2, col]) + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * # TODO: Do this only at the end, not after each function + * if not two_tables: */ - goto __pyx_L10_continue; + __pyx_t_21 = __pyx_v_row1; + __pyx_t_22 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; + } + } + } - /* "Orange/distance/_distance.pyx":215 - * d = 0 - * for col in range(n_cols): - * if mads[col] == -2: # <<<<<<<<<<<<<< - * continue - * + /* "Orange/distance/_distance.pyx":199 + * n_rows2 = x2.shape[0] + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: # <<<<<<<<<<<<<< + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ - } + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } - /* "Orange/distance/_distance.pyx":218 - * continue - * - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] + /* "Orange/distance/_distance.pyx":207 + * distances[row1, row2] = d + * # TODO: Do this only at the end, not after each function + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ - __pyx_t_22 = __pyx_v_row1; - __pyx_t_23 = __pyx_v_col; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_25 = __pyx_v_row2; - __pyx_t_26 = __pyx_v_col; - __pyx_t_27 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_24; - __pyx_v_val2 = __pyx_t_27; + __pyx_t_23 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_23) { - /* "Orange/distance/_distance.pyx":219 + /* "Orange/distance/_distance.pyx":208 + * # TODO: Do this only at the end, not after each function + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: - */ - __pyx_t_28 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_7 = __pyx_t_28; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_28 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_7 = __pyx_t_28; - __pyx_L14_bool_binop_done:; - if (__pyx_t_7) { + */ + __pyx_t_24 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); + if (unlikely(!__pyx_t_24.memview)) __PYX_ERR(0, 208, __pyx_L1_error) + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_24); + __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1); - /* "Orange/distance/_distance.pyx":220 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) + /* "Orange/distance/_distance.pyx":207 + * distances[row1, row2] = d + * # TODO: Do this only at the end, not after each function + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances */ - __pyx_t_29 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_29 * __pyx_v_dist_missing2.strides[0]) )))); + } - /* "Orange/distance/_distance.pyx":219 + /* "Orange/distance/_distance.pyx":209 + * if not two_tables: + * _lower_to_symmetric(distances) + * return distances # <<<<<<<<<<<<<< * - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif mads[col] == -1: + * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, */ - goto __pyx_L13; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_distances)); + __pyx_r = ((PyObject *)__pyx_v_distances); + goto __pyx_L0; - /* "Orange/distance/_distance.pyx":221 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - */ - __pyx_t_30 = __pyx_v_col; - __pyx_t_7 = (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_30 * __pyx_v_mads.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":222 - * d += dist_missing2[col] - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - */ - __pyx_v_ival1 = ((int)__pyx_v_val1); - __pyx_v_ival2 = ((int)__pyx_v_val2); - - /* "Orange/distance/_distance.pyx":223 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":224 - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - * d += dist_missing[col, ival2] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - */ - __pyx_t_31 = __pyx_v_col; - __pyx_t_32 = __pyx_v_ival2; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_31 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_32 * __pyx_v_dist_missing.strides[1]) )))); - - /* "Orange/distance/_distance.pyx":223 - * elif mads[col] == -1: - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): - */ - goto __pyx_L16; - } - - /* "Orange/distance/_distance.pyx":225 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":226 - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] # <<<<<<<<<<<<<< - * elif ival1 != ival2: - * d += 1 - */ - __pyx_t_33 = __pyx_v_col; - __pyx_t_34 = __pyx_v_ival1; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_dist_missing.data + __pyx_t_33 * __pyx_v_dist_missing.strides[0]) ) + __pyx_t_34 * __pyx_v_dist_missing.strides[1]) )))); - - /* "Orange/distance/_distance.pyx":225 - * if npy_isnan(val1): - * d += dist_missing[col, ival2] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - */ - goto __pyx_L16; - } - - /* "Orange/distance/_distance.pyx":227 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: - */ - __pyx_t_7 = ((__pyx_v_ival1 != __pyx_v_ival2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":228 - * d += dist_missing[col, ival1] - * elif ival1 != ival2: - * d += 1 # <<<<<<<<<<<<<< - * elif normalize: - * if npy_isnan(val1): - */ - __pyx_v_d = (__pyx_v_d + 1.0); - - /* "Orange/distance/_distance.pyx":227 - * elif npy_isnan(val2): - * d += dist_missing[col, ival1] - * elif ival1 != ival2: # <<<<<<<<<<<<<< - * d += 1 - * elif normalize: - */ - } - __pyx_L16:; - - /* "Orange/distance/_distance.pyx":221 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif mads[col] == -1: # <<<<<<<<<<<<<< - * ival1, ival2 = int(val1), int(val2) - * if npy_isnan(val1): - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":229 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - */ - __pyx_t_7 = (__pyx_v_normalize != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":230 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":231 - * elif normalize: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - */ - __pyx_t_35 = __pyx_v_col; - __pyx_t_36 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_35 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_36 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - - /* "Orange/distance/_distance.pyx":230 - * d += 1 - * elif normalize: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): - */ - goto __pyx_L17; - } - - /* "Orange/distance/_distance.pyx":232 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":233 - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) / mads[col] / 2 - */ - __pyx_t_37 = __pyx_v_col; - __pyx_t_38 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (((fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_37 * __pyx_v_medians.strides[0]) ))))) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_38 * __pyx_v_mads.strides[0]) )))) / 2.0) + 0.5)); - - /* "Orange/distance/_distance.pyx":232 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: - */ - goto __pyx_L17; - } - - /* "Orange/distance/_distance.pyx":235 - * d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - * else: - * d += fabs(val1 - val2) / mads[col] / 2 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): - */ - /*else*/ { - __pyx_t_39 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + ((fabs((__pyx_v_val1 - __pyx_v_val2)) / (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_39 * __pyx_v_mads.strides[0]) )))) / 2.0)); - } - __pyx_L17:; - - /* "Orange/distance/_distance.pyx":229 - * elif ival1 != ival2: - * d += 1 - * elif normalize: # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":237 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - */ - /*else*/ { - __pyx_t_7 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":238 - * else: - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] - */ - __pyx_t_40 = __pyx_v_col; - __pyx_t_41 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_40 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_41 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":237 - * d += fabs(val1 - val2) / mads[col] / 2 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":239 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: - */ - __pyx_t_7 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":240 - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< - * else: - * d += fabs(val1 - val2) - */ - __pyx_t_42 = __pyx_v_col; - __pyx_t_43 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_42 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_43 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":239 - * if npy_isnan(val1): - * d += fabs(val2 - medians[col]) + mads[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col]) + mads[col] - * else: - */ - goto __pyx_L18; - } - - /* "Orange/distance/_distance.pyx":242 - * d += fabs(val1 - medians[col]) + mads[col] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * - * distances[row1, row2] = d - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); - } - __pyx_L18:; - } - __pyx_L13:; - __pyx_L10_continue:; - } - - /* "Orange/distance/_distance.pyx":244 - * d += fabs(val1 - val2) - * - * distances[row1, row2] = d # <<<<<<<<<<<<<< - * - * if not two_tables: - */ - __pyx_t_44 = __pyx_v_row1; - __pyx_t_45 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_44 * __pyx_v_distances.strides[0]) ) + __pyx_t_45 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - } - } - } - - /* "Orange/distance/_distance.pyx":210 - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * with nogil: # <<<<<<<<<<<<<< - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "Orange/distance/_distance.pyx":246 - * distances[row1, row2] = d - * - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_7 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_7) { - - /* "Orange/distance/_distance.pyx":247 - * - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - - /* "Orange/distance/_distance.pyx":246 - * distances[row1, row2] = d - * - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":248 - * if not two_tables: - * _lower_to_symmetric(distances) - * return distances # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":188 - * - * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + /* "Orange/distance/_distance.pyx":188 + * + * + * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables): */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows_cont", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XDECREF((PyObject *)__pyx_v_distances); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":251 - * +/* "Orange/distance/_distance.pyx":211 + * return distances * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_12manhattan_cols[] = "manhattan_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12manhattan_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_12fix_manhattan_rows[] = "fix_manhattan_rows(ndarray distances, ndarray x1, ndarray x2, ndarray medians, ndarray mads, ndarray dist_missing2_cont, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13fix_manhattan_rows = {"fix_manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12fix_manhattan_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + PyArrayObject *__pyx_v_medians = 0; + PyArrayObject *__pyx_v_mads = 0; + PyArrayObject *__pyx_v_dist_missing2_cont = 0; + char __pyx_v_two_tables; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("manhattan_cols (wrapper)", 0); + __Pyx_RefNannySetupContext("fix_manhattan_rows (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_medians,&__pyx_n_s_mads,&__pyx_n_s_dist_missing2_cont,&__pyx_n_s_two_tables,0}; + PyObject* values[7] = {0,0,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 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -5625,36 +5120,76 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, 1); __PYX_ERR(0, 251, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 1); __PYX_ERR(0, 211, __pyx_L3_error) } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 251, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; - } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 2); __PYX_ERR(0, 211, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_medians)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 3); __PYX_ERR(0, 211, __pyx_L3_error) + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mads)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 4); __PYX_ERR(0, 211, __pyx_L3_error) + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2_cont)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 5); __PYX_ERR(0, 211, __pyx_L3_error) + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 6); __PYX_ERR(0, 211, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows") < 0)) __PYX_ERR(0, 211, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { + 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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + } + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x1 = ((PyArrayObject *)values[1]); + __pyx_v_x2 = ((PyArrayObject *)values[2]); + __pyx_v_medians = ((PyArrayObject *)values[3]); + __pyx_v_mads = ((PyArrayObject *)values[4]); + __pyx_v_dist_missing2_cont = ((PyArrayObject *)values[5]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L3_error) + } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 251, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 251, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 212, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 213, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 214, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 215, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2_cont), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2_cont", 0))) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_medians, __pyx_v_mads, __pyx_v_dist_missing2_cont, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -5665,179 +5200,143 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_cols(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_medians = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_mads = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_v_normalize; - int __pyx_v_n_rows; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables) { + int __pyx_v_n_rows1; + int __pyx_v_n_rows2; int __pyx_v_n_cols; - int __pyx_v_col1; - int __pyx_v_col2; - int __pyx_v_row; + int __pyx_v_row1; + int __pyx_v_row2; + int __pyx_v_col; double __pyx_v_val1; double __pyx_v_val2; double __pyx_v_d; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x; - __Pyx_Buffer __pyx_pybuffer_x; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dist_missing2_cont; + __Pyx_Buffer __pyx_pybuffer_dist_missing2_cont; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; + __Pyx_LocalBuf_ND __pyx_pybuffernd_mads; + __Pyx_Buffer __pyx_pybuffer_mads; + __Pyx_LocalBuf_ND __pyx_pybuffernd_medians; + __Pyx_Buffer __pyx_pybuffer_medians; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; + __Pyx_Buffer __pyx_pybuffer_x1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; + __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - char __pyx_t_3; - npy_intp __pyx_t_4; - npy_intp __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; - int __pyx_t_13; - int __pyx_t_14; - int __pyx_t_15; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - __pyx_t_5numpy_float64_t __pyx_t_18; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; Py_ssize_t __pyx_t_20; - __pyx_t_5numpy_float64_t __pyx_t_21; - int __pyx_t_22; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - Py_ssize_t __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - __Pyx_RefNannySetupContext("manhattan_cols", 0); - __pyx_pybuffer_x.pybuffer.buf = NULL; - __pyx_pybuffer_x.refcount = 0; - __pyx_pybuffernd_x.data = NULL; - __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + __Pyx_memviewslice __pyx_t_25 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_RefNannySetupContext("fix_manhattan_rows", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + __pyx_pybuffer_x1.pybuffer.buf = NULL; + __pyx_pybuffer_x1.refcount = 0; + __pyx_pybuffernd_x1.data = NULL; + __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1; + __pyx_pybuffer_x2.pybuffer.buf = NULL; + __pyx_pybuffer_x2.refcount = 0; + __pyx_pybuffernd_x2.data = NULL; + __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + __pyx_pybuffer_medians.pybuffer.buf = NULL; + __pyx_pybuffer_medians.refcount = 0; + __pyx_pybuffernd_medians.data = NULL; + __pyx_pybuffernd_medians.rcbuffer = &__pyx_pybuffer_medians; + __pyx_pybuffer_mads.pybuffer.buf = NULL; + __pyx_pybuffer_mads.refcount = 0; + __pyx_pybuffernd_mads.data = NULL; + __pyx_pybuffernd_mads.rcbuffer = &__pyx_pybuffer_mads; + __pyx_pybuffer_dist_missing2_cont.pybuffer.buf = NULL; + __pyx_pybuffer_dist_missing2_cont.refcount = 0; + __pyx_pybuffernd_dist_missing2_cont.data = NULL; + __pyx_pybuffernd_dist_missing2_cont.rcbuffer = &__pyx_pybuffer_dist_missing2_cont; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 251, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - - /* "Orange/distance/_distance.pyx":253 - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] medians = fit_params["medians"] # <<<<<<<<<<<<<< - * double [:] mads = fit_params["mads"] - * char normalize = fit_params["normalize"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_medians); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_medians = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":254 - * cdef: - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] # <<<<<<<<<<<<<< - * char normalize = fit_params["normalize"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_mads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_mads = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":255 - * double [:] medians = fit_params["medians"] - * double [:] mads = fit_params["mads"] - * char normalize = fit_params["normalize"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, col1, col2, row - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_normalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_normalize = __pyx_t_3; + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_pybuffernd_medians.diminfo[0].strides = __pyx_pybuffernd_medians.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_medians.diminfo[0].shape = __pyx_pybuffernd_medians.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_pybuffernd_mads.diminfo[0].strides = __pyx_pybuffernd_mads.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mads.diminfo[0].shape = __pyx_pybuffernd_mads.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2_cont, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_pybuffernd_dist_missing2_cont.diminfo[0].strides = __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2_cont.diminfo[0].shape = __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":261 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":222 + * double val1, val2, d * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) + * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: */ - __pyx_t_4 = (__pyx_v_x->dimensions[0]); - __pyx_t_5 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_4; - __pyx_v_n_cols = __pyx_t_5; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":262 + /* "Orange/distance/_distance.pyx":223 * - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] if two_tables else 0 # <<<<<<<<<<<<<< * with nogil: - * for col1 in range(n_cols): + * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 262, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_2 = (__pyx_v_x2->dimensions[0]); + } else { + __pyx_t_2 = 0; + } + __pyx_v_n_rows2 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":263 - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":224 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ { #ifdef WITH_THREAD @@ -5846,361 +5345,217 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_U #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":264 - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":225 + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * d = 0 + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): */ - __pyx_t_10 = __pyx_v_n_cols; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_col1 = __pyx_t_11; + __pyx_t_3 = __pyx_v_n_rows1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":265 + /* "Orange/distance/_distance.pyx":226 * with nogil: - * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * if npy_isnan(distances[row1, row2]): + * d = 0 */ - __pyx_t_12 = __pyx_v_col1; - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_col2 = __pyx_t_13; + if ((__pyx_v_two_tables != 0)) { + __pyx_t_5 = __pyx_v_n_rows2; + } else { + __pyx_t_5 = __pyx_v_row1; + } + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":266 - * for col1 in range(n_cols): - * for col2 in range(col1): - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":227 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_v_d = 0.0; + __pyx_t_7 = __pyx_v_row1; + __pyx_t_8 = __pyx_v_row2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":267 - * for col2 in range(col1): - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: + /* "Orange/distance/_distance.pyx":228 + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":268 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) + /* "Orange/distance/_distance.pyx":229 + * if npy_isnan(distances[row1, row2]): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col1; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row; - __pyx_t_20 = __pyx_v_col2; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":269 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - */ - __pyx_t_22 = (__pyx_v_normalize != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":270 - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) # <<<<<<<<<<<<<< - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - * if npy_isnan(val1): - */ - __pyx_t_23 = __pyx_v_col1; - __pyx_t_24 = __pyx_v_col1; - __pyx_v_val1 = ((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_23 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_24 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":271 - * if normalize: - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":230 + * d = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< * if npy_isnan(val1): * if npy_isnan(val2): */ - __pyx_t_25 = __pyx_v_col2; - __pyx_t_26 = __pyx_v_col2; - __pyx_v_val2 = ((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_25 * __pyx_v_medians.strides[0]) )))) / (2.0 * (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_26 * __pyx_v_mads.strides[0]) ))))); + __pyx_t_12 = __pyx_v_row1; + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row2; + __pyx_t_16 = __pyx_v_col; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":272 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":231 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += dist_missing2_cont[col] */ - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":273 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":232 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + * d += dist_missing2_cont[col] * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":274 + /* "Orange/distance/_distance.pyx":233 * if npy_isnan(val1): * if npy_isnan(val2): - * d += 1 # <<<<<<<<<<<<<< + * d += dist_missing2_cont[col] # <<<<<<<<<<<<<< * else: - * d += fabs(val2) + 0.5 + * d += fabs(val2 - medians[col]) + mads[col] */ - __pyx_v_d = (__pyx_v_d + 1.0); + __pyx_t_18 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2_cont.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":273 - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":232 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += 1 + * d += dist_missing2_cont[col] * else: */ goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":276 - * d += 1 + /* "Orange/distance/_distance.pyx":235 + * d += dist_missing2_cont[col] * else: - * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 + * d += fabs(val1 - medians[col]) + mads[col] */ /*else*/ { - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + __pyx_t_19 = __pyx_v_col; + __pyx_t_20 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_medians.diminfo[0].strides)))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_mads.diminfo[0].strides)))); } __pyx_L14:; - /* "Orange/distance/_distance.pyx":272 - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) + /* "Orange/distance/_distance.pyx":231 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< * if npy_isnan(val2): - * d += 1 + * d += dist_missing2_cont[col] */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":236 * else: - * d += fabs(val2) + 0.5 + * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + * d += fabs(val1 - medians[col]) + mads[col] * else: */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":278 - * d += fabs(val2) + 0.5 + /* "Orange/distance/_distance.pyx":237 + * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): - * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< + * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< * else: * d += fabs(val1 - val2) */ - __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); + __pyx_t_21 = __pyx_v_col; + __pyx_t_22 = __pyx_v_col; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_medians.diminfo[0].strides)))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_mads.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":277 + /* "Orange/distance/_distance.pyx":236 * else: - * d += fabs(val2) + 0.5 + * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1) + 0.5 + * d += fabs(val1 - medians[col]) + mads[col] * else: */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":280 - * d += fabs(val1) + 0.5 + /* "Orange/distance/_distance.pyx":239 + * d += fabs(val1 - medians[col]) + mads[col] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val1): + * distances[row1, row2] = d + * if not two_tables: */ /*else*/ { __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); } __pyx_L13:; - - /* "Orange/distance/_distance.pyx":269 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if normalize: # <<<<<<<<<<<<<< - * val1 = (val1 - medians[col1]) / (2 * mads[col1]) - * val2 = (val2 - medians[col2]) / (2 * mads[col2]) - */ - goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":282 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - */ - /*else*/ { - __pyx_t_22 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":283 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) - */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":284 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: - */ - __pyx_t_27 = __pyx_v_col1; - __pyx_t_28 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":285 - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":284 - * if npy_isnan(val1): - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< - * + fabs(medians[col1] - medians[col2]) - * else: - */ - __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_27 * __pyx_v_mads.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_28 * __pyx_v_mads.strides[0]) )))) + fabs(((*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_29 * __pyx_v_medians.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_30 * __pyx_v_medians.strides[0]) ))))))); - - /* "Orange/distance/_distance.pyx":283 - * else: - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * d += mads[col1] + mads[col2] \ - * + fabs(medians[col1] - medians[col2]) - */ - goto __pyx_L16; - } - - /* "Orange/distance/_distance.pyx":287 - * + fabs(medians[col1] - medians[col2]) - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] - */ - /*else*/ { - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_31 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_32 * __pyx_v_mads.strides[0]) ))))); - } - __pyx_L16:; - - /* "Orange/distance/_distance.pyx":282 - * d += fabs(val1 - val2) - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * d += mads[col1] + mads[col2] \ - */ - goto __pyx_L15; - } - - /* "Orange/distance/_distance.pyx":288 - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - */ - __pyx_t_22 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_22) { - - /* "Orange/distance/_distance.pyx":289 - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): - * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":240 * else: * d += fabs(val1 - val2) + * distances[row1, row2] = d # <<<<<<<<<<<<<< + * if not two_tables: + * _lower_to_symmetric(distances) */ - __pyx_t_33 = __pyx_v_col2; - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_medians.data + __pyx_t_33 * __pyx_v_medians.strides[0]) ))))) + (*((double *) ( /* dim=0 */ (__pyx_v_mads.data + __pyx_t_34 * __pyx_v_mads.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":288 - * else: - * d += fabs(val2 - medians[col1]) + mads[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - */ - goto __pyx_L15; - } + __pyx_t_23 = __pyx_v_row1; + __pyx_t_24 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":291 - * d += fabs(val1 - medians[col2]) + mads[col2] - * else: - * d += fabs(val1 - val2) # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d - * return distances + /* "Orange/distance/_distance.pyx":227 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); - } - __pyx_L15:; - } - __pyx_L12:; } - - /* "Orange/distance/_distance.pyx":292 - * else: - * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; - __pyx_t_37 = __pyx_v_col2; - __pyx_t_38 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } } } - /* "Orange/distance/_distance.pyx":263 - * n_rows, n_cols = x.shape[0], x.shape[1] - * distances = np.zeros((n_cols, n_cols), dtype=float) + /* "Orange/distance/_distance.pyx":224 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * for col2 in range(col1): + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): */ /*finally:*/ { /*normal exit:*/{ @@ -6213,643 +5568,109 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_cols(CYTHON_U } } - /* "Orange/distance/_distance.pyx":293 + /* "Orange/distance/_distance.pyx":241 * d += fabs(val1 - val2) - * distances[col1, col2] = distances[col2, col1] = d + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_9) { + + /* "Orange/distance/_distance.pyx":242 + * distances[row1, row2] = d + * if not two_tables: + * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * return distances + * + */ + __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); + if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 242, __pyx_L1_error) + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_25); + __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); + + /* "Orange/distance/_distance.pyx":241 + * d += fabs(val1 - val2) + * distances[row1, row2] = d + * if not two_tables: # <<<<<<<<<<<<<< + * _lower_to_symmetric(distances) + * return distances + */ + } + + /* "Orange/distance/_distance.pyx":243 + * if not two_tables: + * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_INCREF(((PyObject *)__pyx_v_distances)); + __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":251 - * + /* "Orange/distance/_distance.pyx":211 + * return distances * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mads.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_medians.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mads.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_medians.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_medians, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_mads, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":296 +/* "Orange/distance/_distance.pyx":246 * * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_14p_nonzero[] = "p_nonzero(ndarray x)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_14p_nonzero}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized[] = "fix_manhattan_rows_normalized(ndarray distances, ndarray x1, ndarray x2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized = {"fix_manhattan_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; + char __pyx_v_two_tables; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 296, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { - int __pyx_v_row; - int __pyx_v_nonzeros; - int __pyx_v_nonnans; - double __pyx_v_val; - __Pyx_LocalBuf_ND __pyx_pybuffernd_x; - __Pyx_Buffer __pyx_pybuffer_x; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("p_nonzero", 0); - __pyx_pybuffer_x.pybuffer.buf = NULL; - __pyx_pybuffer_x.refcount = 0; - __pyx_pybuffernd_x.data = NULL; - __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 296, __pyx_L1_error) - } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - - /* "Orange/distance/_distance.pyx":301 - * double val - * - * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< - * for row in range(len(x)): - * val = x[row] - */ - __pyx_v_nonzeros = 0; - __pyx_v_nonnans = 0; - - /* "Orange/distance/_distance.pyx":302 - * - * nonzeros = nonnans = 0 - * for row in range(len(x)): # <<<<<<<<<<<<<< - * val = x[row] - * if not npy_isnan(val): - */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 302, __pyx_L1_error) - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_row = __pyx_t_2; - - /* "Orange/distance/_distance.pyx":303 - * nonzeros = nonnans = 0 - * for row in range(len(x)): - * val = x[row] # <<<<<<<<<<<<<< - * if not npy_isnan(val): - * nonnans += 1 - */ - __pyx_t_3 = __pyx_v_row; - __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - - /* "Orange/distance/_distance.pyx":304 - * for row in range(len(x)): - * val = x[row] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: - */ - __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); - if (__pyx_t_4) { - - /* "Orange/distance/_distance.pyx":305 - * val = x[row] - * if not npy_isnan(val): - * nonnans += 1 # <<<<<<<<<<<<<< - * if val != 0: - * nonzeros += 1 - */ - __pyx_v_nonnans = (__pyx_v_nonnans + 1); - - /* "Orange/distance/_distance.pyx":306 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * return float(nonzeros) / nonnans - */ - __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); - if (__pyx_t_4) { - - /* "Orange/distance/_distance.pyx":307 - * nonnans += 1 - * if val != 0: - * nonzeros += 1 # <<<<<<<<<<<<<< - * return float(nonzeros) / nonnans - * - */ - __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - - /* "Orange/distance/_distance.pyx":306 - * if not npy_isnan(val): - * nonnans += 1 - * if val != 0: # <<<<<<<<<<<<<< - * nonzeros += 1 - * return float(nonzeros) / nonnans - */ - } - - /* "Orange/distance/_distance.pyx":304 - * for row in range(len(x)): - * val = x[row] - * if not npy_isnan(val): # <<<<<<<<<<<<<< - * nonnans += 1 - * if val != 0: - */ - } - } - - /* "Orange/distance/_distance.pyx":308 - * if val != 0: - * nonzeros += 1 - * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":296 - * - * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.p_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "Orange/distance/_distance.pyx":311 - * - * - * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss - */ - -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_rows(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - double __pyx_v_d; - double __pyx_v_val; - int __pyx_v_row; - int __pyx_v_col; - int __pyx_v_n_rows; - int __pyx_v_n_cols; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - int __pyx_t_12; - Py_ssize_t __pyx_t_13; - int __pyx_t_14; - Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - Py_ssize_t __pyx_t_18; - Py_ssize_t __pyx_t_19; - Py_ssize_t __pyx_t_20; - Py_ssize_t __pyx_t_21; - __Pyx_RefNannySetupContext("_abs_rows", 0); - - /* "Orange/distance/_distance.pyx":317 - * int row, col, n_rows, n_cols - * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * abss = np.empty(n_rows) - * with nogil: - */ - __pyx_t_1 = (__pyx_v_x.shape[0]); - __pyx_t_2 = (__pyx_v_x.shape[1]); - __pyx_v_n_rows = __pyx_t_1; - __pyx_v_n_cols = __pyx_t_2; - - /* "Orange/distance/_distance.pyx":318 - * - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) # <<<<<<<<<<<<<< - * with nogil: - * for row in range(n_rows): - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_abss = __pyx_t_8; - __pyx_t_8.memview = NULL; - __pyx_t_8.data = NULL; - - /* "Orange/distance/_distance.pyx":319 - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) - * with nogil: # <<<<<<<<<<<<<< - * for row in range(n_rows): - * d = 0 - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "Orange/distance/_distance.pyx":320 - * abss = np.empty(n_rows) - * with nogil: - * for row in range(n_rows): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): - */ - __pyx_t_9 = __pyx_v_n_rows; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_row = __pyx_t_10; - - /* "Orange/distance/_distance.pyx":321 - * with nogil: - * for row in range(n_rows): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":322 - * for row in range(n_rows): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * continue - */ - __pyx_t_11 = __pyx_v_n_cols; - for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { - __pyx_v_col = __pyx_t_12; - - /* "Orange/distance/_distance.pyx":323 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val = x[row, col] - */ - __pyx_t_13 = __pyx_v_col; - __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_13 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_14) { - - /* "Orange/distance/_distance.pyx":324 - * for col in range(n_cols): - * if vars[col] == -2: - * continue # <<<<<<<<<<<<<< - * val = x[row, col] - * if vars[col] == -1: - */ - goto __pyx_L8_continue; - - /* "Orange/distance/_distance.pyx":323 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val = x[row, col] - */ - } - - /* "Orange/distance/_distance.pyx":325 - * if vars[col] == -2: - * continue - * val = x[row, col] # <<<<<<<<<<<<<< - * if vars[col] == -1: - * if npy_isnan(val): - */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col; - __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_15 * __pyx_v_x.strides[0]) ) + __pyx_t_16 * __pyx_v_x.strides[1]) ))); - - /* "Orange/distance/_distance.pyx":326 - * continue - * val = x[row, col] - * if vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val): - * d += means[col] - */ - __pyx_t_17 = __pyx_v_col; - __pyx_t_14 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_17 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_14) { - - /* "Orange/distance/_distance.pyx":327 - * val = x[row, col] - * if vars[col] == -1: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] - * elif val != 0: - */ - __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_14) { - - /* "Orange/distance/_distance.pyx":328 - * if vars[col] == -1: - * if npy_isnan(val): - * d += means[col] # <<<<<<<<<<<<<< - * elif val != 0: - * d += 1 - */ - __pyx_t_18 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) )))); - - /* "Orange/distance/_distance.pyx":327 - * val = x[row, col] - * if vars[col] == -1: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] - * elif val != 0: - */ - goto __pyx_L12; - } - - /* "Orange/distance/_distance.pyx":329 - * if npy_isnan(val): - * d += means[col] - * elif val != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: - */ - __pyx_t_14 = ((__pyx_v_val != 0.0) != 0); - if (__pyx_t_14) { - - /* "Orange/distance/_distance.pyx":330 - * d += means[col] - * elif val != 0: - * d += 1 # <<<<<<<<<<<<<< - * else: - * if npy_isnan(val): - */ - __pyx_v_d = (__pyx_v_d + 1.0); - - /* "Orange/distance/_distance.pyx":329 - * if npy_isnan(val): - * d += means[col] - * elif val != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: - */ - } - __pyx_L12:; - - /* "Orange/distance/_distance.pyx":326 - * continue - * val = x[row, col] - * if vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val): - * d += means[col] - */ - goto __pyx_L11; - } - - /* "Orange/distance/_distance.pyx":332 - * d += 1 - * else: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] ** 2 + vars[col] - * else: - */ - /*else*/ { - __pyx_t_14 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_14) { - - /* "Orange/distance/_distance.pyx":333 - * else: - * if npy_isnan(val): - * d += means[col] ** 2 + vars[col] # <<<<<<<<<<<<<< - * else: - * d += val ** 2 - */ - __pyx_t_19 = __pyx_v_col; - __pyx_t_20 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_19 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":332 - * d += 1 - * else: - * if npy_isnan(val): # <<<<<<<<<<<<<< - * d += means[col] ** 2 + vars[col] - * else: - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":335 - * d += means[col] ** 2 + vars[col] - * else: - * d += val ** 2 # <<<<<<<<<<<<<< - * abss[row] = sqrt(d) - * return abss - */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); - } - __pyx_L13:; - } - __pyx_L11:; - __pyx_L8_continue:; - } - - /* "Orange/distance/_distance.pyx":336 - * else: - * d += val ** 2 - * abss[row] = sqrt(d) # <<<<<<<<<<<<<< - * return abss - * - */ - __pyx_t_21 = __pyx_v_row; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_21 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); - } - } - - /* "Orange/distance/_distance.pyx":319 - * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_rows) - * with nogil: # <<<<<<<<<<<<<< - * for row in range(n_rows): - * d = 0 - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "Orange/distance/_distance.pyx":337 - * d += val ** 2 - * abss[row] = sqrt(d) - * return abss # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "Orange/distance/_distance.pyx":311 - * - * - * cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_AddTraceback("Orange.distance._distance._abs_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "Orange/distance/_distance.pyx":340 - * - * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_16cosine_rows[] = "cosine_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17cosine_rows = {"cosine_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17cosine_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16cosine_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x1 = 0; - PyArrayObject *__pyx_v_x2 = 0; - char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cosine_rows (wrapper)", 0); + __Pyx_RefNannySetupContext("fix_manhattan_rows_normalized (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distances,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -6865,26 +5686,26 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *_ kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 1); __PYX_ERR(0, 340, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 1); __PYX_ERR(0, 246, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 2); __PYX_ERR(0, 340, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 2); __PYX_ERR(0, 246, __pyx_L3_error) } case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, 3); __PYX_ERR(0, 340, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 3); __PYX_ERR(0, 246, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_rows") < 0)) __PYX_ERR(0, 340, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows_normalized") < 0)) __PYX_ERR(0, 246, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6894,22 +5715,23 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *_ values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L3_error) - __pyx_v_fit_params = values[3]; + __pyx_v_distances = ((PyArrayObject *)values[0]); + __pyx_v_x1 = ((PyArrayObject *)values[1]); + __pyx_v_x2 = ((PyArrayObject *)values[2]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 249, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 340, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 246, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 340, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 341, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16cosine_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 246, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 247, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -6920,10 +5742,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17cosine_rows(PyObject *_ return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_dist_missing2 = { 0, 0, { 0 }, { 0 }, { 0 } }; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -6933,52 +5752,39 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUS double __pyx_v_val1; double __pyx_v_val2; double __pyx_v_d; - __Pyx_memviewslice __pyx_v_abs1 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_abs2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; + __Pyx_Buffer __pyx_pybuffer_distances; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; int __pyx_t_5; - Py_ssize_t __pyx_t_6; + int __pyx_t_6; Py_ssize_t __pyx_t_7; Py_ssize_t __pyx_t_8; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - int __pyx_t_14; - int __pyx_t_15; - int __pyx_t_16; - int __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - Py_ssize_t __pyx_t_20; - Py_ssize_t __pyx_t_21; - Py_ssize_t __pyx_t_22; - __pyx_t_5numpy_float64_t __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - __pyx_t_5numpy_float64_t __pyx_t_26; - int __pyx_t_27; - Py_ssize_t __pyx_t_28; - Py_ssize_t __pyx_t_29; - Py_ssize_t __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - __Pyx_RefNannySetupContext("cosine_rows", 0); + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + Py_ssize_t __pyx_t_13; + __pyx_t_5numpy_float64_t __pyx_t_14; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + __pyx_t_5numpy_float64_t __pyx_t_17; + Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_19; + __Pyx_memviewslice __pyx_t_20 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_RefNannySetupContext("fix_manhattan_rows_normalized", 0); + __pyx_pybuffer_distances.pybuffer.buf = NULL; + __pyx_pybuffer_distances.refcount = 0; + __pyx_pybuffernd_distances.data = NULL; + __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -6989,237 +5795,49 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUS __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) + } + __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":345 - * fit_params): - * cdef: - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * double [:] means = fit_params["means"] - * double [:] dist_missing2 = fit_params["dist_missing2"] - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 345, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":346 - * cdef: - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * double [:] dist_missing2 = fit_params["dist_missing2"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 346, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":347 - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] - * double [:] dist_missing2 = fit_params["dist_missing2"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_dist_missing2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 347, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_dist_missing2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":354 - * double [:, :] distances + /* "Orange/distance/_distance.pyx":254 + * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ + * n_rows2 = x2.shape[0] if two_tables else 0 + * with nogil: */ - __pyx_t_3 = (__pyx_v_x1->dimensions[0]); - __pyx_t_4 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x1->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":355 + /* "Orange/distance/_distance.pyx":255 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) - */ - __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - - /* "Orange/distance/_distance.pyx":356 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == __pyx_t_6); - if (__pyx_t_5) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_6 == __pyx_t_7); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":357 - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) # <<<<<<<<<<<<<< - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - */ - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dist_missing2, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 357, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__pyx_t_7 == __pyx_t_8); - } - } - } - - /* "Orange/distance/_distance.pyx":356 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] - * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ # <<<<<<<<<<<<<< - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) - */ - if (unlikely(!(__pyx_t_5 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 356, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":358 - * assert n_cols == x2.shape[1] == len(vars) == len(means) \ - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) # <<<<<<<<<<<<<< - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - */ - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x1)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 358, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_abs1 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":359 - * == len(dist_missing2) - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 # <<<<<<<<<<<<<< - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * + * n_rows2 = x2.shape[0] if two_tables else 0 # <<<<<<<<<<<<<< + * with nogil: + * for row1 in range(n_rows1): */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x2)); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 359, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_rows(__pyx_t_9, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __pyx_t_10; - __pyx_t_10.memview = NULL; - __pyx_t_10.data = NULL; + __pyx_t_2 = (__pyx_v_x2->dimensions[0]); } else { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_abs1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __pyx_t_10; - __pyx_t_10.memview = NULL; - __pyx_t_10.data = NULL; + __pyx_t_2 = 0; } - __pyx_v_abs2 = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_v_n_rows2 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":360 - * abs1 = _abs_rows(x1, means, vars) - * abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< - * - * with nogil: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); - __pyx_t_1 = 0; - __pyx_t_12 = 0; - __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); - __pyx_t_13 = 0; - __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 360, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; - - /* "Orange/distance/_distance.pyx":362 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * + /* "Orange/distance/_distance.pyx":256 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -7231,422 +5849,209 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUS #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":363 - * + /* "Orange/distance/_distance.pyx":257 + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 + * if npy_isnan(distances[row1, row2]): */ - __pyx_t_14 = __pyx_v_n_rows1; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row1 = __pyx_t_15; + __pyx_t_3 = __pyx_v_n_rows1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":364 + /* "Orange/distance/_distance.pyx":258 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * d = 0 - * for col in range(n_cols): + * if npy_isnan(distances[row1, row2]): + * d = 0 */ if ((__pyx_v_two_tables != 0)) { - __pyx_t_16 = __pyx_v_n_rows2; + __pyx_t_5 = __pyx_v_n_rows2; } else { - __pyx_t_16 = __pyx_v_row1; + __pyx_t_5 = __pyx_v_row1; } - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { - __pyx_v_row2 = __pyx_t_17; - - /* "Orange/distance/_distance.pyx":365 - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":366 - * for row2 in range(n_rows2 if two_tables else row1): - * d = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * continue - */ - __pyx_t_18 = __pyx_v_n_cols; - for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { - __pyx_v_col = __pyx_t_19; - - /* "Orange/distance/_distance.pyx":367 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - */ - __pyx_t_20 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_20 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":368 - * for col in range(n_cols): - * if vars[col] == -2: - * continue # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - */ - goto __pyx_L10_continue; - - /* "Orange/distance/_distance.pyx":367 - * d = 0 - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - */ - } - - /* "Orange/distance/_distance.pyx":369 - * if vars[col] == -2: - * continue - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - */ - __pyx_t_21 = __pyx_v_row1; - __pyx_t_22 = __pyx_v_col; - __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_24 = __pyx_v_row2; - __pyx_t_25 = __pyx_v_col; - __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_23; - __pyx_v_val2 = __pyx_t_26; - - /* "Orange/distance/_distance.pyx":370 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: - */ - __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L14_bool_binop_done:; - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":371 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] # <<<<<<<<<<<<<< - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ - */ - __pyx_t_28 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_dist_missing2.data + __pyx_t_28 * __pyx_v_dist_missing2.strides[0]) )))); - - /* "Orange/distance/_distance.pyx":370 - * continue - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += dist_missing2[col] - * elif vars[col] == -1: - */ - goto __pyx_L13; - } - - /* "Orange/distance/_distance.pyx":372 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: - */ - __pyx_t_29 = __pyx_v_col; - __pyx_t_5 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_29 * __pyx_v_vars.strides[0]) ))) == -1.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":373 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - */ - __pyx_t_27 = (npy_isnan(__pyx_v_val1) != 0); - if (!__pyx_t_27) { - goto __pyx_L18_next_or; - } else { - } - __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); - if (!__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L17_bool_binop_done; - } - __pyx_L18_next_or:; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":374 - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: # <<<<<<<<<<<<<< - * d += means[col] - * elif val1 != 0 and val2 != 0: + /* "Orange/distance/_distance.pyx":259 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< + * d = 0 + * for col in range(n_cols): */ - __pyx_t_27 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L17_bool_binop_done; - } - __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L17_bool_binop_done:; + __pyx_t_7 = __pyx_v_row1; + __pyx_t_8 = __pyx_v_row2; + __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":373 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] + /* "Orange/distance/_distance.pyx":260 + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): + * d = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] */ - if (__pyx_t_5) { + __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":375 - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: - * d += means[col] # <<<<<<<<<<<<<< - * elif val1 != 0 and val2 != 0: - * d += 1 + /* "Orange/distance/_distance.pyx":261 + * if npy_isnan(distances[row1, row2]): + * d = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): */ - __pyx_t_30 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_30 * __pyx_v_means.strides[0]) )))); + __pyx_t_10 = __pyx_v_n_cols; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":373 - * d += dist_missing2[col] - * elif vars[col] == -1: - * if npy_isnan(val1) and val2 != 0 \ # <<<<<<<<<<<<<< - * or npy_isnan(val2) and val1 != 0: - * d += means[col] + /* "Orange/distance/_distance.pyx":262 + * d = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - goto __pyx_L16; - } + __pyx_t_12 = __pyx_v_row1; + __pyx_t_13 = __pyx_v_col; + __pyx_t_14 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_row2; + __pyx_t_16 = __pyx_v_col; + __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_14; + __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":376 - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":263 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * d += 1 */ - __pyx_t_27 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_27) { - } else { - __pyx_t_5 = __pyx_t_27; - goto __pyx_L21_bool_binop_done; - } - __pyx_t_27 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_27; - __pyx_L21_bool_binop_done:; - if (__pyx_t_5) { + __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":377 - * d += means[col] - * elif val1 != 0 and val2 != 0: - * d += 1 # <<<<<<<<<<<<<< - * else: + /* "Orange/distance/_distance.pyx":264 + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: */ - __pyx_v_d = (__pyx_v_d + 1.0); - - /* "Orange/distance/_distance.pyx":376 - * or npy_isnan(val2) and val1 != 0: - * d += means[col] - * elif val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * d += 1 - * else: - */ - } - __pyx_L16:; + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":372 - * if npy_isnan(val1) and npy_isnan(val2): - * d += dist_missing2[col] - * elif vars[col] == -1: # <<<<<<<<<<<<<< - * if npy_isnan(val1) and val2 != 0 \ - * or npy_isnan(val2) and val1 != 0: + /* "Orange/distance/_distance.pyx":265 + * if npy_isnan(val1): + * if npy_isnan(val2): + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += fabs(val2) + 0.5 */ - goto __pyx_L13; - } + __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":379 - * d += 1 - * else: - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":264 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * d += 1 + * else: */ - /*else*/ { - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":380 - * else: - * if npy_isnan(val1): - * d += val2 * means[col] # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":267 + * d += 1 + * else: + * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< * elif npy_isnan(val2): - * d += val1 * means[col] + * d += fabs(val1) + 0.5 */ - __pyx_t_31 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))))); + /*else*/ { + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + } + __pyx_L14:; - /* "Orange/distance/_distance.pyx":379 - * d += 1 - * else: + /* "Orange/distance/_distance.pyx":263 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col] - * elif npy_isnan(val2): + * if npy_isnan(val2): + * d += 1 */ - goto __pyx_L23; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":381 - * if npy_isnan(val1): - * d += val2 * means[col] + /* "Orange/distance/_distance.pyx":268 + * else: + * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col] + * d += fabs(val1) + 0.5 * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":382 - * d += val2 * means[col] + /* "Orange/distance/_distance.pyx":269 + * d += fabs(val2) + 0.5 * elif npy_isnan(val2): - * d += val1 * means[col] # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< * else: - * d += val1 * val2 + * d += fabs(val1 - val2) */ - __pyx_t_32 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":381 - * if npy_isnan(val1): - * d += val2 * means[col] + /* "Orange/distance/_distance.pyx":268 + * else: + * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col] + * d += fabs(val1) + 0.5 * else: */ - goto __pyx_L23; + goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":384 - * d += val1 * means[col] + /* "Orange/distance/_distance.pyx":271 + * d += fabs(val1) + 0.5 * else: - * d += val1 * val2 # <<<<<<<<<<<<<< - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * distances[row1, row2] = d + * if not two_tables: */ /*else*/ { - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); } - __pyx_L23:; + __pyx_L13:; } - __pyx_L13:; - __pyx_L10_continue:; - } - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":272 * else: - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] # <<<<<<<<<<<<<< - * if d < 0: # clip off any numeric errors - * d = 0 - */ - __pyx_t_33 = __pyx_v_row1; - __pyx_t_34 = __pyx_v_row2; - __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abs1.data + __pyx_t_33 * __pyx_v_abs1.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abs2.data + __pyx_t_34 * __pyx_v_abs2.strides[0]) ))))); - - /* "Orange/distance/_distance.pyx":386 - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: - */ - __pyx_t_5 = ((__pyx_v_d < 0.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":387 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors - * d = 0 # <<<<<<<<<<<<<< - * elif d > 1: - * d = 1 - */ - __pyx_v_d = 0.0; - - /* "Orange/distance/_distance.pyx":386 - * d += val1 * val2 - * d = 1 - d / abs1[row1] / abs2[row2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: - */ - goto __pyx_L24; - } - - /* "Orange/distance/_distance.pyx":388 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[row1, row2] = d - */ - __pyx_t_5 = ((__pyx_v_d > 1.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":389 - * d = 0 - * elif d > 1: - * d = 1 # <<<<<<<<<<<<<< - * distances[row1, row2] = d + * d += fabs(val1 - val2) + * distances[row1, row2] = d # <<<<<<<<<<<<<< * if not two_tables: + * _lower_to_symmetric(distances) */ - __pyx_v_d = 1.0; + __pyx_t_18 = __pyx_v_row1; + __pyx_t_19 = __pyx_v_row2; + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":388 - * if d < 0: # clip off any numeric errors + /* "Orange/distance/_distance.pyx":259 + * for row1 in range(n_rows1): + * for row2 in range(n_rows2 if two_tables else row1): + * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[row1, row2] = d + * for col in range(n_cols): */ } - __pyx_L24:; - - /* "Orange/distance/_distance.pyx":390 - * elif d > 1: - * d = 1 - * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) - */ - __pyx_t_35 = __pyx_v_row1; - __pyx_t_36 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; } } } - /* "Orange/distance/_distance.pyx":362 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * + /* "Orange/distance/_distance.pyx":256 + * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): @@ -7662,35 +6067,38 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":391 - * d = 1 - * distances[row1, row2] = d + /* "Orange/distance/_distance.pyx":273 + * d += fabs(val1 - val2) + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ - __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_5) { + __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":392 - * distances[row1, row2] = d + /* "Orange/distance/_distance.pyx":274 + * distances[row1, row2] = d * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances * */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); + __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); + if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 274, __pyx_L1_error) + __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_20); + __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); - /* "Orange/distance/_distance.pyx":391 - * d = 1 - * distances[row1, row2] = d + /* "Orange/distance/_distance.pyx":273 + * d += fabs(val1 - val2) + * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":275 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -7698,160 +6106,276 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16cosine_rows(CYTHON_UNUS * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_INCREF(((PyObject *)__pyx_v_distances)); + __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":246 + * + * + * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, + */ + + /* function exit code */ + __pyx_L1_error:; + __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":278 * * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=1] medians, + * np.ndarray[np.float64_t, ndim=1] mads, */ +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_16manhattan_cols[] = "manhattan_cols(ndarray x, ndarray medians, ndarray mads, char normalize)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16manhattan_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_x = 0; + PyArrayObject *__pyx_v_medians = 0; + PyArrayObject *__pyx_v_mads = 0; + char __pyx_v_normalize; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("manhattan_cols (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_medians,&__pyx_n_s_mads,&__pyx_n_s_normalize,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_medians)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 1); __PYX_ERR(0, 278, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mads)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 2); __PYX_ERR(0, 278, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_normalize)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 3); __PYX_ERR(0, 278, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 278, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + 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); + } + __pyx_v_x = ((PyArrayObject *)values[0]); + __pyx_v_medians = ((PyArrayObject *)values[1]); + __pyx_v_mads = ((PyArrayObject *)values[2]); + __pyx_v_normalize = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_normalize == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 281, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 278, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 279, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_medians, __pyx_v_mads, __pyx_v_normalize); + /* function exit code */ + goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.cosine_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; - goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); - __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_dist_missing2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abs1, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abs2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":396 - * - * - * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss - */ - -static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - double __pyx_v_d; - double __pyx_v_val; - int __pyx_v_row; - int __pyx_v_col; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize) { int __pyx_v_n_rows; int __pyx_v_n_cols; - int __pyx_v_nan_cont; + int __pyx_v_col1; + int __pyx_v_col2; + int __pyx_v_row; + double __pyx_v_val1; + double __pyx_v_val2; + double __pyx_v_d; + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_mads; + __Pyx_Buffer __pyx_pybuffer_mads; + __Pyx_LocalBuf_ND __pyx_pybuffernd_medians; + __Pyx_Buffer __pyx_pybuffer_medians; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; - Py_ssize_t __pyx_t_11; + int __pyx_t_11; int __pyx_t_12; - Py_ssize_t __pyx_t_13; - int __pyx_t_14; - int __pyx_t_15; - Py_ssize_t __pyx_t_16; + int __pyx_t_13; + Py_ssize_t __pyx_t_14; + Py_ssize_t __pyx_t_15; + __pyx_t_5numpy_float64_t __pyx_t_16; Py_ssize_t __pyx_t_17; Py_ssize_t __pyx_t_18; - Py_ssize_t __pyx_t_19; - Py_ssize_t __pyx_t_20; - __Pyx_RefNannySetupContext("_abs_cols", 0); + __pyx_t_5numpy_float64_t __pyx_t_19; + int __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + Py_ssize_t __pyx_t_26; + Py_ssize_t __pyx_t_27; + Py_ssize_t __pyx_t_28; + Py_ssize_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + __Pyx_RefNannySetupContext("manhattan_cols", 0); + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + __pyx_pybuffer_medians.pybuffer.buf = NULL; + __pyx_pybuffer_medians.refcount = 0; + __pyx_pybuffernd_medians.data = NULL; + __pyx_pybuffernd_medians.rcbuffer = &__pyx_pybuffer_medians; + __pyx_pybuffer_mads.pybuffer.buf = NULL; + __pyx_pybuffer_mads.refcount = 0; + __pyx_pybuffernd_mads.data = NULL; + __pyx_pybuffernd_mads.rcbuffer = &__pyx_pybuffer_mads; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + } + __pyx_pybuffernd_medians.diminfo[0].strides = __pyx_pybuffernd_medians.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_medians.diminfo[0].shape = __pyx_pybuffernd_medians.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + } + __pyx_pybuffernd_mads.diminfo[0].strides = __pyx_pybuffernd_mads.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mads.diminfo[0].shape = __pyx_pybuffernd_mads.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":402 - * int row, col, n_rows, n_cols, nan_cont + /* "Orange/distance/_distance.pyx":287 + * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * abss = np.empty(n_cols) + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: */ - __pyx_t_1 = (__pyx_v_x.shape[0]); - __pyx_t_2 = (__pyx_v_x.shape[1]); + __pyx_t_1 = (__pyx_v_x->dimensions[0]); + __pyx_t_2 = (__pyx_v_x->dimensions[1]); __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":403 + /* "Orange/distance/_distance.pyx":288 * * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) # <<<<<<<<<<<<<< + * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: - * for col in range(n_cols): + * for col1 in range(n_cols): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 403, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_abss = __pyx_t_8; - __pyx_t_8.memview = NULL; - __pyx_t_8.data = NULL; + __pyx_v_distances = __pyx_t_7; + __pyx_t_7.memview = NULL; + __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":404 + /* "Orange/distance/_distance.pyx":289 * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: + * for col1 in range(n_cols): + * for col2 in range(col1): */ { #ifdef WITH_THREAD @@ -7860,168 +6384,313 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":405 - * abss = np.empty(n_cols) + /* "Orange/distance/_distance.pyx":290 + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: - * for col in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col] == -2: - * abss[col] = 1 + * for col1 in range(n_cols): # <<<<<<<<<<<<<< + * for col2 in range(col1): + * d = 0 */ - __pyx_t_9 = __pyx_v_n_cols; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_col = __pyx_t_10; + __pyx_t_8 = __pyx_v_n_cols; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_col1 = __pyx_t_9; - /* "Orange/distance/_distance.pyx":406 - * with nogil: - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * abss[col] = 1 - * continue - */ - __pyx_t_11 = __pyx_v_col; - __pyx_t_12 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_11 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_12) { - - /* "Orange/distance/_distance.pyx":407 - * for col in range(n_cols): - * if vars[col] == -2: - * abss[col] = 1 # <<<<<<<<<<<<<< - * continue - * d = 0 - */ - __pyx_t_13 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_13 * __pyx_v_abss.strides[0]) )) = 1.0; - - /* "Orange/distance/_distance.pyx":408 - * if vars[col] == -2: - * abss[col] = 1 - * continue # <<<<<<<<<<<<<< - * d = 0 - * nan_cont = 0 - */ - goto __pyx_L6_continue; - - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":291 * with nogil: - * for col in range(n_cols): - * if vars[col] == -2: # <<<<<<<<<<<<<< - * abss[col] = 1 - * continue + * for col1 in range(n_cols): + * for col2 in range(col1): # <<<<<<<<<<<<<< + * d = 0 + * for row in range(n_rows): */ - } + __pyx_t_10 = __pyx_v_col1; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_col2 = __pyx_t_11; + + /* "Orange/distance/_distance.pyx":292 + * for col1 in range(n_cols): + * for col2 in range(col1): + * d = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + */ + __pyx_v_d = 0.0; + + /* "Orange/distance/_distance.pyx":293 + * for col2 in range(col1): + * d = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + */ + __pyx_t_12 = __pyx_v_n_rows; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row = __pyx_t_13; - /* "Orange/distance/_distance.pyx":409 - * abss[col] = 1 - * continue - * d = 0 # <<<<<<<<<<<<<< - * nan_cont = 0 - * for row in range(n_rows): + /* "Orange/distance/_distance.pyx":294 + * d = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - __pyx_v_d = 0.0; + __pyx_t_14 = __pyx_v_row; + __pyx_t_15 = __pyx_v_col1; + __pyx_t_16 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_17 = __pyx_v_row; + __pyx_t_18 = __pyx_v_col2; + __pyx_t_19 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_16; + __pyx_v_val2 = __pyx_t_19; - /* "Orange/distance/_distance.pyx":410 - * continue - * d = 0 - * nan_cont = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val = x[row, col] + /* "Orange/distance/_distance.pyx":295 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * if normalize: */ - __pyx_v_nan_cont = 0; + __pyx_t_20 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":411 - * d = 0 - * nan_cont = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val = x[row, col] - * if npy_isnan(val): + /* "Orange/distance/_distance.pyx":296 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if normalize: + * d += 1 */ - __pyx_t_14 = __pyx_v_n_rows; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_row = __pyx_t_15; + __pyx_t_20 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_20) { + + /* "Orange/distance/_distance.pyx":297 + * if npy_isnan(val1): + * if npy_isnan(val2): + * if normalize: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + __pyx_t_20 = (__pyx_v_normalize != 0); + if (__pyx_t_20) { + + /* "Orange/distance/_distance.pyx":298 + * if npy_isnan(val2): + * if normalize: + * d += 1 # <<<<<<<<<<<<<< + * else: + * d += mads[col1] + mads[col2] \ + */ + __pyx_v_d = (__pyx_v_d + 1.0); + + /* "Orange/distance/_distance.pyx":297 + * if npy_isnan(val1): + * if npy_isnan(val2): + * if normalize: # <<<<<<<<<<<<<< + * d += 1 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":300 + * d += 1 + * else: + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + /*else*/ { + __pyx_t_21 = __pyx_v_col1; + __pyx_t_22 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":301 + * else: + * d += mads[col1] + mads[col2] \ + * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< + * else: + * if normalize: + */ + __pyx_t_23 = __pyx_v_col1; + __pyx_t_24 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":300 + * d += 1 + * else: + * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< + * + fabs(medians[col1] - medians[col2]) + * else: + */ + __pyx_v_d = (__pyx_v_d + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_mads.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_mads.diminfo[0].strides))) + fabs(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_medians.diminfo[0].strides)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_medians.diminfo[0].strides)))))); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":296 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if normalize: + * d += 1 + */ + goto __pyx_L13; + } + + /* "Orange/distance/_distance.pyx":303 + * + fabs(medians[col1] - medians[col2]) + * else: + * if normalize: # <<<<<<<<<<<<<< + * d += fabs(val2) + 0.5 + * else: + */ + /*else*/ { + __pyx_t_20 = (__pyx_v_normalize != 0); + if (__pyx_t_20) { + + /* "Orange/distance/_distance.pyx":304 + * else: + * if normalize: + * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] + */ + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); + + /* "Orange/distance/_distance.pyx":303 + * + fabs(medians[col1] - medians[col2]) + * else: + * if normalize: # <<<<<<<<<<<<<< + * d += fabs(val2) + 0.5 + * else: + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":306 + * d += fabs(val2) + 0.5 + * else: + * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< + * else: + * if npy_isnan(val2): + */ + /*else*/ { + __pyx_t_25 = __pyx_v_col1; + __pyx_t_26 = __pyx_v_col1; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val2 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_medians.diminfo[0].strides)))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_mads.diminfo[0].strides)))); + } + __pyx_L15:; + } + __pyx_L13:; + + /* "Orange/distance/_distance.pyx":295 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * if normalize: + */ + goto __pyx_L12; + } + + /* "Orange/distance/_distance.pyx":308 + * d += fabs(val2 - medians[col1]) + mads[col1] + * else: + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if normalize: + * d += fabs(val1) + 0.5 + */ + /*else*/ { + __pyx_t_20 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":412 - * nan_cont = 0 - * for row in range(n_rows): - * val = x[row, col] # <<<<<<<<<<<<<< - * if npy_isnan(val): - * nan_cont += 1 + /* "Orange/distance/_distance.pyx":309 + * else: + * if npy_isnan(val2): + * if normalize: # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: */ - __pyx_t_16 = __pyx_v_row; - __pyx_t_17 = __pyx_v_col; - __pyx_v_val = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x.data + __pyx_t_16 * __pyx_v_x.strides[0]) ) + __pyx_t_17 * __pyx_v_x.strides[1]) ))); + __pyx_t_20 = (__pyx_v_normalize != 0); + if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":413 - * for row in range(n_rows): - * val = x[row, col] - * if npy_isnan(val): # <<<<<<<<<<<<<< - * nan_cont += 1 - * else: + /* "Orange/distance/_distance.pyx":310 + * if npy_isnan(val2): + * if normalize: + * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - medians[col2]) + mads[col2] */ - __pyx_t_12 = (npy_isnan(__pyx_v_val) != 0); - if (__pyx_t_12) { + __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":414 - * val = x[row, col] - * if npy_isnan(val): - * nan_cont += 1 # <<<<<<<<<<<<<< - * else: - * d += val ** 2 + /* "Orange/distance/_distance.pyx":309 + * else: + * if npy_isnan(val2): + * if normalize: # <<<<<<<<<<<<<< + * d += fabs(val1) + 0.5 + * else: */ - __pyx_v_nan_cont = (__pyx_v_nan_cont + 1); + goto __pyx_L17; + } - /* "Orange/distance/_distance.pyx":413 - * for row in range(n_rows): - * val = x[row, col] - * if npy_isnan(val): # <<<<<<<<<<<<<< - * nan_cont += 1 - * else: + /* "Orange/distance/_distance.pyx":312 + * d += fabs(val1) + 0.5 + * else: + * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< + * else: + * d += fabs(val1 - val2) */ - goto __pyx_L11; - } + /*else*/ { + __pyx_t_27 = __pyx_v_col2; + __pyx_t_28 = __pyx_v_col2; + __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_medians.diminfo[0].strides)))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_mads.diminfo[0].strides)))); + } + __pyx_L17:; - /* "Orange/distance/_distance.pyx":416 - * nan_cont += 1 - * else: - * d += val ** 2 # <<<<<<<<<<<<<< - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) + /* "Orange/distance/_distance.pyx":308 + * d += fabs(val2 - medians[col1]) + mads[col1] + * else: + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if normalize: + * d += fabs(val1) + 0.5 */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + pow(__pyx_v_val, 2.0)); - } - __pyx_L11:; - } + goto __pyx_L16; + } - /* "Orange/distance/_distance.pyx":417 - * else: - * d += val ** 2 - * d += nan_cont * (means[col] ** 2 + vars[col]) # <<<<<<<<<<<<<< - * abss[col] = sqrt(d) - * return abss + /* "Orange/distance/_distance.pyx":314 + * d += fabs(val1 - medians[col2]) + mads[col2] + * else: + * d += fabs(val1 - val2) # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = d + * return distances */ - __pyx_t_18 = __pyx_v_col; - __pyx_t_19 = __pyx_v_col; - __pyx_v_d = (__pyx_v_d + (__pyx_v_nan_cont * (pow((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_18 * __pyx_v_means.strides[0]) ))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))))); + /*else*/ { + __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); + } + __pyx_L16:; + } + __pyx_L12:; + } - /* "Orange/distance/_distance.pyx":418 - * d += val ** 2 - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) # <<<<<<<<<<<<<< - * return abss + /* "Orange/distance/_distance.pyx":315 + * else: + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< + * return distances * */ - __pyx_t_20 = __pyx_v_col; - *((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_20 * __pyx_v_abss.strides[0]) )) = sqrt(__pyx_v_d); - __pyx_L6_continue:; + __pyx_t_29 = __pyx_v_col1; + __pyx_t_30 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + __pyx_t_31 = __pyx_v_col2; + __pyx_t_32 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_31 * __pyx_v_distances.strides[0]) ) + __pyx_t_32 * __pyx_v_distances.strides[1]) )) = __pyx_v_d; + } } } - /* "Orange/distance/_distance.pyx":404 + /* "Orange/distance/_distance.pyx":289 * n_rows, n_cols = x.shape[0], x.shape[1] - * abss = np.empty(n_cols) + * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< - * for col in range(n_cols): - * if vars[col] == -2: + * for col1 in range(n_cols): + * for col2 in range(col1): */ /*finally:*/ { /*normal exit:*/{ @@ -8034,26 +6703,26 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli } } - /* "Orange/distance/_distance.pyx":419 - * d += nan_cont * (means[col] ** 2 + vars[col]) - * abss[col] = sqrt(d) - * return abss # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":316 + * d += fabs(val1 - val2) + * distances[col1, col2] = distances[col2, col1] = d + * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_abss, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":278 * * - * cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): # <<<<<<<<<<<<<< - * cdef: - * double [:] abss + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=1] medians, + * np.ndarray[np.float64_t, ndim=1] mads, */ /* function exit code */ @@ -8062,80 +6731,47 @@ static PyObject *__pyx_f_6Orange_8distance_9_distance__abs_cols(__Pyx_memviewsli __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_AddTraceback("Orange.distance._distance._abs_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mads.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_medians.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; __pyx_L0:; - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mads.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_medians.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":422 +/* "Orange/distance/_distance.pyx":319 * * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: - * double [:] vars = fit_params["vars"] + * int row, nonzeros, nonnans */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_19cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_18cosine_cols[] = "cosine_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_19cosine_cols = {"cosine_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_19cosine_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_18cosine_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_19cosine_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_18p_nonzero[] = "p_nonzero(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_19p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_19p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_18p_nonzero}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cosine_cols (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, 1); __PYX_ERR(0, 422, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cosine_cols") < 0)) __PYX_ERR(0, 422, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cosine_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 422, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 422, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_18cosine_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 319, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_18p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ goto __pyx_L0; @@ -8146,688 +6782,482 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_19cosine_cols(PyObject *_ return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_18cosine_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_vars = { 0, 0, { 0 }, { 0 }, { 0 } }; - __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_v_n_rows; - int __pyx_v_n_cols; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { int __pyx_v_row; - int __pyx_v_col1; - int __pyx_v_col2; - double __pyx_v_val1; - double __pyx_v_val2; - double __pyx_v_d; - __Pyx_memviewslice __pyx_v_abss = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyArrayObject *__pyx_v_distances = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_distances; - __Pyx_Buffer __pyx_pybuffer_distances; + int __pyx_v_nonzeros; + int __pyx_v_nonnans; + double __pyx_v_val; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - Py_ssize_t __pyx_t_7; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyArrayObject *__pyx_t_12 = NULL; - int __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - int __pyx_t_17; - Py_ssize_t __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; - Py_ssize_t __pyx_t_21; - int __pyx_t_22; - int __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - __pyx_t_5numpy_float64_t __pyx_t_26; - Py_ssize_t __pyx_t_27; - Py_ssize_t __pyx_t_28; - __pyx_t_5numpy_float64_t __pyx_t_29; - int __pyx_t_30; - Py_ssize_t __pyx_t_31; - Py_ssize_t __pyx_t_32; - Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; - Py_ssize_t __pyx_t_35; - Py_ssize_t __pyx_t_36; - Py_ssize_t __pyx_t_37; - Py_ssize_t __pyx_t_38; - Py_ssize_t __pyx_t_39; - Py_ssize_t __pyx_t_40; - __Pyx_RefNannySetupContext("cosine_cols", 0); - __pyx_pybuffer_distances.pybuffer.buf = NULL; - __pyx_pybuffer_distances.refcount = 0; - __pyx_pybuffernd_distances.data = NULL; - __pyx_pybuffernd_distances.rcbuffer = &__pyx_pybuffer_distances; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("p_nonzero", 0); __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 422, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 319, __pyx_L1_error) } - __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - - /* "Orange/distance/_distance.pyx":424 - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] vars = fit_params["vars"] # <<<<<<<<<<<<<< - * double [:] means = fit_params["means"] - * - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 424, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_vars = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":425 - * cdef: - * double [:] vars = fit_params["vars"] - * double [:] means = fit_params["means"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, row, col1, col2 - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_means); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 425, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_means = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":434 - * np.ndarray[np.float64_t, ndim=2] distances + /* "Orange/distance/_distance.pyx":324 + * double val * - * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) + * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< + * for row in range(len(x)): + * val = x[row] */ - __pyx_t_3 = (__pyx_v_x->dimensions[0]); - __pyx_t_4 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_v_nonzeros = 0; + __pyx_v_nonnans = 0; - /* "Orange/distance/_distance.pyx":435 + /* "Orange/distance/_distance.pyx":325 * - * n_rows, n_cols = x.shape[0], x.shape[1] - * assert n_cols == len(vars) == len(means) # <<<<<<<<<<<<<< - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_vars, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 435, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (__pyx_v_n_cols == __pyx_t_5); - if (__pyx_t_6) { - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_means, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 435, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (__pyx_t_5 == __pyx_t_7); - } - if (unlikely(!(__pyx_t_6 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 435, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":436 - * n_rows, n_cols = x.shape[0], x.shape[1] - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) # <<<<<<<<<<<<<< - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - */ - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_x)); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 436, __pyx_L1_error) - __pyx_t_1 = __pyx_f_6Orange_8distance_9_distance__abs_cols(__pyx_t_8, __pyx_v_means, __pyx_v_vars); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 436, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_abss = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":437 - * assert n_cols == len(vars) == len(means) - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< - * for col1 in range(n_cols): - * if vars[col1] == -2: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); - __pyx_t_1 = 0; - __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 437, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 437, __pyx_L1_error) - __pyx_t_12 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); - __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack); - if (unlikely(__pyx_t_13 < 0)) { - PyErr_Fetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_14, __pyx_t_15, __pyx_t_16); - } - } - __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 437, __pyx_L1_error) - } - __pyx_t_12 = 0; - __pyx_v_distances = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "Orange/distance/_distance.pyx":438 - * abss = _abs_cols(x, means, vars) - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 - */ - __pyx_t_13 = __pyx_v_n_cols; - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_13; __pyx_t_17+=1) { - __pyx_v_col1 = __pyx_t_17; - - /* "Orange/distance/_distance.pyx":439 - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * if vars[col1] == -2: # <<<<<<<<<<<<<< - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - */ - __pyx_t_18 = __pyx_v_col1; - __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_6) { - - /* "Orange/distance/_distance.pyx":440 - * for col1 in range(n_cols): - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< - * continue - * with nogil: - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); - __Pyx_INCREF(__pyx_slice_); - __Pyx_GIVEREF(__pyx_slice_); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_slice_); - __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_11, __pyx_float_1_0) < 0)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_col1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__2); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); - __pyx_t_11 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_distances), __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "Orange/distance/_distance.pyx":441 - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 - * continue # <<<<<<<<<<<<<< - * with nogil: - * for col2 in range(col1): - */ - goto __pyx_L3_continue; - - /* "Orange/distance/_distance.pyx":439 - * distances = np.zeros((n_cols, n_cols), dtype=float) - * for col1 in range(n_cols): - * if vars[col1] == -2: # <<<<<<<<<<<<<< - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - */ - } - - /* "Orange/distance/_distance.pyx":442 - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - * with nogil: # <<<<<<<<<<<<<< - * for col2 in range(col1): - * if vars[col2] == -2: - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "Orange/distance/_distance.pyx":443 - * continue - * with nogil: - * for col2 in range(col1): # <<<<<<<<<<<<<< - * if vars[col2] == -2: - * continue + * nonzeros = nonnans = 0 + * for row in range(len(x)): # <<<<<<<<<<<<<< + * val = x[row] + * if not npy_isnan(val): */ - __pyx_t_19 = __pyx_v_col1; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_col2 = __pyx_t_20; + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 325, __pyx_L1_error) + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":444 - * with nogil: - * for col2 in range(col1): - * if vars[col2] == -2: # <<<<<<<<<<<<<< - * continue - * d = 0 + /* "Orange/distance/_distance.pyx":326 + * nonzeros = nonnans = 0 + * for row in range(len(x)): + * val = x[row] # <<<<<<<<<<<<<< + * if not npy_isnan(val): + * nonnans += 1 */ - __pyx_t_21 = __pyx_v_col2; - __pyx_t_6 = (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_21 * __pyx_v_vars.strides[0]) ))) == -2.0) != 0); - if (__pyx_t_6) { + __pyx_t_3 = __pyx_v_row; + __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - /* "Orange/distance/_distance.pyx":445 - * for col2 in range(col1): - * if vars[col2] == -2: - * continue # <<<<<<<<<<<<<< - * d = 0 - * for row in range(n_rows): + /* "Orange/distance/_distance.pyx":327 + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: */ - goto __pyx_L11_continue; + __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); + if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":444 - * with nogil: - * for col2 in range(col1): - * if vars[col2] == -2: # <<<<<<<<<<<<<< - * continue - * d = 0 + /* "Orange/distance/_distance.pyx":328 + * val = x[row] + * if not npy_isnan(val): + * nonnans += 1 # <<<<<<<<<<<<<< + * if val != 0: + * nonzeros += 1 */ - } + __pyx_v_nonnans = (__pyx_v_nonnans + 1); - /* "Orange/distance/_distance.pyx":446 - * if vars[col2] == -2: - * continue - * d = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":329 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ - __pyx_v_d = 0.0; + __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); + if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":447 - * continue - * d = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): + /* "Orange/distance/_distance.pyx":330 + * nonnans += 1 + * if val != 0: + * nonzeros += 1 # <<<<<<<<<<<<<< + * return float(nonzeros) / nonnans + * */ - __pyx_t_22 = __pyx_v_n_rows; - for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { - __pyx_v_row = __pyx_t_23; + __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - /* "Orange/distance/_distance.pyx":448 - * d = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] + /* "Orange/distance/_distance.pyx":329 + * if not npy_isnan(val): + * nonnans += 1 + * if val != 0: # <<<<<<<<<<<<<< + * nonzeros += 1 + * return float(nonzeros) / nonnans */ - __pyx_t_24 = __pyx_v_row; - __pyx_t_25 = __pyx_v_col1; - __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_27 = __pyx_v_row; - __pyx_t_28 = __pyx_v_col2; - __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_26; - __pyx_v_val2 = __pyx_t_29; - - /* "Orange/distance/_distance.pyx":449 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += means[col1] * means[col2] - * elif npy_isnan(val1): - */ - __pyx_t_30 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_30) { - } else { - __pyx_t_6 = __pyx_t_30; - goto __pyx_L17_bool_binop_done; - } - __pyx_t_30 = (npy_isnan(__pyx_v_val2) != 0); - __pyx_t_6 = __pyx_t_30; - __pyx_L17_bool_binop_done:; - if (__pyx_t_6) { + } - /* "Orange/distance/_distance.pyx":450 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] # <<<<<<<<<<<<<< - * elif npy_isnan(val1): - * d += val2 * means[col1] + /* "Orange/distance/_distance.pyx":327 + * for row in range(len(x)): + * val = x[row] + * if not npy_isnan(val): # <<<<<<<<<<<<<< + * nonnans += 1 + * if val != 0: */ - __pyx_t_31 = __pyx_v_col1; - __pyx_t_32 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + ((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_31 * __pyx_v_means.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_32 * __pyx_v_means.strides[0]) ))))); + } + } - /* "Orange/distance/_distance.pyx":449 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1) and npy_isnan(val2): # <<<<<<<<<<<<<< - * d += means[col1] * means[col2] - * elif npy_isnan(val1): + /* "Orange/distance/_distance.pyx":331 + * if val != 0: + * nonzeros += 1 + * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< + * + * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): */ - goto __pyx_L16; - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; - /* "Orange/distance/_distance.pyx":451 - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] - * elif npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col1] - * elif npy_isnan(val2): + /* "Orange/distance/_distance.pyx":319 + * + * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans */ - __pyx_t_6 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_6) { - /* "Orange/distance/_distance.pyx":452 - * d += means[col1] * means[col2] - * elif npy_isnan(val1): - * d += val2 * means[col1] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * d += val1 * means[col2] - */ - __pyx_t_33 = __pyx_v_col1; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val2 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_33 * __pyx_v_means.strides[0]) ))))); + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("Orange.distance._distance.p_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":451 - * if npy_isnan(val1) and npy_isnan(val2): - * d += means[col1] * means[col2] - * elif npy_isnan(val1): # <<<<<<<<<<<<<< - * d += val2 * means[col1] - * elif npy_isnan(val2): +/* "Orange/distance/_distance.pyx":333 + * return float(nonzeros) / nonnans + * + * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< + * cdef: + * int row, n_cols, n_rows */ - goto __pyx_L16; - } - /* "Orange/distance/_distance.pyx":453 - * elif npy_isnan(val1): - * d += val2 * means[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col2] - * else: - */ - __pyx_t_6 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_6) { +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_20any_nan_row[] = "any_nan_row(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_21any_nan_row = {"any_nan_row", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_21any_nan_row, METH_O, __pyx_doc_6Orange_8distance_9_distance_20any_nan_row}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("any_nan_row (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 333, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_20any_nan_row(__pyx_self, ((PyArrayObject *)__pyx_v_x)); - /* "Orange/distance/_distance.pyx":454 - * d += val2 * means[col1] - * elif npy_isnan(val2): - * d += val1 * means[col2] # <<<<<<<<<<<<<< - * else: - * d += val1 * val2 - */ - __pyx_t_34 = __pyx_v_col2; - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_34 * __pyx_v_means.strides[0]) ))))); + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "Orange/distance/_distance.pyx":453 - * elif npy_isnan(val1): - * d += val2 * means[col1] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * d += val1 * means[col2] - * else: - */ - goto __pyx_L16; - } +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { + int __pyx_v_row; + int __pyx_v_n_cols; + int __pyx_v_n_rows; + PyArrayObject *__pyx_v_flags = 0; + int __pyx_v_col; + __Pyx_LocalBuf_ND __pyx_pybuffernd_flags; + __Pyx_Buffer __pyx_pybuffer_flags; + __Pyx_LocalBuf_ND __pyx_pybuffernd_x; + __Pyx_Buffer __pyx_pybuffer_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + Py_ssize_t __pyx_t_16; + Py_ssize_t __pyx_t_17; + int __pyx_t_18; + Py_ssize_t __pyx_t_19; + __Pyx_RefNannySetupContext("any_nan_row", 0); + __pyx_pybuffer_flags.pybuffer.buf = NULL; + __pyx_pybuffer_flags.refcount = 0; + __pyx_pybuffernd_flags.data = NULL; + __pyx_pybuffernd_flags.rcbuffer = &__pyx_pybuffer_flags; + __pyx_pybuffer_x.pybuffer.buf = NULL; + __pyx_pybuffer_x.refcount = 0; + __pyx_pybuffernd_x.data = NULL; + __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 333, __pyx_L1_error) + } + __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":456 - * d += val1 * means[col2] - * else: - * d += val1 * val2 # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":338 + * np.ndarray[np.int8_t, ndim=1] flags * - * d = 1 - d / abss[col1] / abss[col2] + * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< + * flags = np.zeros(x.shape[0], dtype=np.int8) + * with nogil: */ - /*else*/ { - __pyx_v_d = (__pyx_v_d + (__pyx_v_val1 * __pyx_v_val2)); - } - __pyx_L16:; - } + __pyx_t_1 = (__pyx_v_x->dimensions[0]); + __pyx_t_2 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":458 - * d += val1 * val2 + /* "Orange/distance/_distance.pyx":339 * - * d = 1 - d / abss[col1] / abss[col2] # <<<<<<<<<<<<<< - * if d < 0: # clip off any numeric errors - * d = 0 + * n_rows, n_cols = x.shape[0], x.shape[1] + * flags = np.zeros(x.shape[0], dtype=np.int8) # <<<<<<<<<<<<<< + * with nogil: + * for row in range(n_rows): + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_x->dimensions[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_8 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flags.rcbuffer->pybuffer); + __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flags.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_9 < 0)) { + PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flags.rcbuffer->pybuffer, (PyObject*)__pyx_v_flags, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); + } + } + __pyx_pybuffernd_flags.diminfo[0].strides = __pyx_pybuffernd_flags.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_flags.diminfo[0].shape = __pyx_pybuffernd_flags.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 339, __pyx_L1_error) + } + __pyx_t_8 = 0; + __pyx_v_flags = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; + + /* "Orange/distance/_distance.pyx":340 + * n_rows, n_cols = x.shape[0], x.shape[1] + * flags = np.zeros(x.shape[0], dtype=np.int8) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * for col in range(n_cols): */ - __pyx_t_35 = __pyx_v_col1; - __pyx_t_36 = __pyx_v_col2; - __pyx_v_d = (1.0 - ((__pyx_v_d / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_35 * __pyx_v_abss.strides[0]) )))) / (*((double *) ( /* dim=0 */ (__pyx_v_abss.data + __pyx_t_36 * __pyx_v_abss.strides[0]) ))))); + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "Orange/distance/_distance.pyx":459 - * - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: + /* "Orange/distance/_distance.pyx":341 + * flags = np.zeros(x.shape[0], dtype=np.int8) + * with nogil: + * for row in range(n_rows): # <<<<<<<<<<<<<< + * for col in range(n_cols): + * if npy_isnan(x[row, col]): */ - __pyx_t_6 = ((__pyx_v_d < 0.0) != 0); - if (__pyx_t_6) { + __pyx_t_9 = __pyx_v_n_rows; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_9; __pyx_t_13+=1) { + __pyx_v_row = __pyx_t_13; - /* "Orange/distance/_distance.pyx":460 - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors - * d = 0 # <<<<<<<<<<<<<< - * elif d > 1: - * d = 1 + /* "Orange/distance/_distance.pyx":342 + * with nogil: + * for row in range(n_rows): + * for col in range(n_cols): # <<<<<<<<<<<<<< + * if npy_isnan(x[row, col]): + * flags[row] = 1 */ - __pyx_v_d = 0.0; + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":459 - * - * d = 1 - d / abss[col1] / abss[col2] - * if d < 0: # clip off any numeric errors # <<<<<<<<<<<<<< - * d = 0 - * elif d > 1: + /* "Orange/distance/_distance.pyx":343 + * for row in range(n_rows): + * for col in range(n_cols): + * if npy_isnan(x[row, col]): # <<<<<<<<<<<<<< + * flags[row] = 1 + * break */ - goto __pyx_L19; - } + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides))) != 0); + if (__pyx_t_18) { - /* "Orange/distance/_distance.pyx":461 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d + /* "Orange/distance/_distance.pyx":344 + * for col in range(n_cols): + * if npy_isnan(x[row, col]): + * flags[row] = 1 # <<<<<<<<<<<<<< + * break + * return flags */ - __pyx_t_6 = ((__pyx_v_d > 1.0) != 0); - if (__pyx_t_6) { + __pyx_t_19 = __pyx_v_row; + *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_flags.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_flags.diminfo[0].strides) = 1; - /* "Orange/distance/_distance.pyx":462 - * d = 0 - * elif d > 1: - * d = 1 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = d - * return distances + /* "Orange/distance/_distance.pyx":345 + * if npy_isnan(x[row, col]): + * flags[row] = 1 + * break # <<<<<<<<<<<<<< + * return flags + * */ - __pyx_v_d = 1.0; + goto __pyx_L9_break; - /* "Orange/distance/_distance.pyx":461 - * if d < 0: # clip off any numeric errors - * d = 0 - * elif d > 1: # <<<<<<<<<<<<<< - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d + /* "Orange/distance/_distance.pyx":343 + * for row in range(n_rows): + * for col in range(n_cols): + * if npy_isnan(x[row, col]): # <<<<<<<<<<<<<< + * flags[row] = 1 + * break */ } - __pyx_L19:; - - /* "Orange/distance/_distance.pyx":463 - * elif d > 1: - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_37 = __pyx_v_col1; - __pyx_t_38 = __pyx_v_col2; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - __pyx_t_39 = __pyx_v_col2; - __pyx_t_40 = __pyx_v_col1; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - __pyx_L11_continue:; } + __pyx_L9_break:; } + } - /* "Orange/distance/_distance.pyx":442 - * distances[col1, :] = distances[:, col1] = 1.0 - * continue - * with nogil: # <<<<<<<<<<<<<< - * for col2 in range(col1): - * if vars[col2] == -2: + /* "Orange/distance/_distance.pyx":340 + * n_rows, n_cols = x.shape[0], x.shape[1] + * flags = np.zeros(x.shape[0], dtype=np.int8) + * with nogil: # <<<<<<<<<<<<<< + * for row in range(n_rows): + * for col in range(n_cols): */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L10; - } - __pyx_L10:; + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L5; } - } - __pyx_L3_continue:; + __pyx_L5:; + } } - /* "Orange/distance/_distance.pyx":464 - * d = 1 - * distances[col1, col2] = distances[col2, col1] = d - * return distances # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":346 + * flags[row] = 1 + * break + * return flags # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_distances)); - __pyx_r = ((PyObject *)__pyx_v_distances); + __Pyx_INCREF(((PyObject *)__pyx_v_flags)); + __pyx_r = ((PyObject *)__pyx_v_flags); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":422 - * + /* "Orange/distance/_distance.pyx":333 + * return float(nonzeros) / nonnans * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< * cdef: - * double [:] vars = fit_params["vars"] + * int row, n_cols, n_rows */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flags.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("Orange.distance._distance.cosine_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("Orange.distance._distance.any_nan_row", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_distances.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flags.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_vars, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_means, 1); - __PYX_XDEC_MEMVIEW(&__pyx_v_abss, 1); - __Pyx_XDECREF((PyObject *)__pyx_v_distances); + __Pyx_XDECREF((PyObject *)__pyx_v_flags); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":467 +/* "Orange/distance/_distance.pyx":349 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< + * np.ndarray[np.int8_t, ndim=2] nonzeros2, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_20jaccard_rows[] = "jaccard_rows(ndarray x1, ndarray x2, char two_tables, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_21jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_20jaccard_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_22jaccard_rows[] = "jaccard_rows(ndarray nonzeros1, ndarray nonzeros2, ndarray x1, ndarray x2, ndarray nans1, ndarray nans2, ndarray ps, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_23jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_22jaccard_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_nonzeros1 = 0; + PyArrayObject *__pyx_v_nonzeros2 = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; + PyArrayObject *__pyx_v_nans1 = 0; + PyArrayObject *__pyx_v_nans2 = 0; + PyArrayObject *__pyx_v_ps = 0; char __pyx_v_two_tables; - PyObject *__pyx_v_fit_params = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("jaccard_rows (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_two_tables,&__pyx_n_s_fit_params,0}; - PyObject* values[4] = {0,0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nonzeros1,&__pyx_n_s_nonzeros2,&__pyx_n_s_x1,&__pyx_n_s_x2,&__pyx_n_s_nans1,&__pyx_n_s_nans2,&__pyx_n_s_ps,&__pyx_n_s_two_tables,0}; + PyObject* values[8] = {0,0,0,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 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); @@ -8838,51 +7268,84 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject * kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros1)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 1); __PYX_ERR(0, 467, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 1); __PYX_ERR(0, 349, __pyx_L3_error) } case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 2); __PYX_ERR(0, 467, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 2); __PYX_ERR(0, 349, __pyx_L3_error) } case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 3); __PYX_ERR(0, 349, __pyx_L3_error) + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans1)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 4); __PYX_ERR(0, 349, __pyx_L3_error) + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 5); __PYX_ERR(0, 349, __pyx_L3_error) + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ps)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 6); __PYX_ERR(0, 349, __pyx_L3_error) + } + case 7: + if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, 3); __PYX_ERR(0, 467, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 7); __PYX_ERR(0, 349, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 467, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 349, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 8) { 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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + values[7] = PyTuple_GET_ITEM(__pyx_args, 7); } - __pyx_v_x1 = ((PyArrayObject *)values[0]); - __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 469, __pyx_L3_error) - __pyx_v_fit_params = values[3]; + __pyx_v_nonzeros1 = ((PyArrayObject *)values[0]); + __pyx_v_nonzeros2 = ((PyArrayObject *)values[1]); + __pyx_v_x1 = ((PyArrayObject *)values[2]); + __pyx_v_x2 = ((PyArrayObject *)values[3]); + __pyx_v_nans1 = ((PyArrayObject *)values[4]); + __pyx_v_nans2 = ((PyArrayObject *)values[5]); + __pyx_v_ps = ((PyArrayObject *)values[6]); + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[7]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 467, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 349, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 467, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 468, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros1), __pyx_ptype_5numpy_ndarray, 1, "nonzeros1", 0))) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros2), __pyx_ptype_5numpy_ndarray, 1, "nonzeros2", 0))) __PYX_ERR(0, 350, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 351, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 352, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans1), __pyx_ptype_5numpy_ndarray, 1, "nans1", 0))) __PYX_ERR(0, 353, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans2), __pyx_ptype_5numpy_ndarray, 1, "nans2", 0))) __PYX_ERR(0, 354, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(__pyx_self, __pyx_v_nonzeros1, __pyx_v_nonzeros2, __pyx_v_x1, __pyx_v_x2, __pyx_v_nans1, __pyx_v_nans2, __pyx_v_ps, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -8893,35 +7356,46 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_21jaccard_rows(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; int __pyx_v_row1; int __pyx_v_row2; int __pyx_v_col; - double __pyx_v_val1; - double __pyx_v_val2; - double __pyx_v_intersection; - double __pyx_v_union; + __pyx_t_5numpy_float64_t __pyx_v_val1; + __pyx_t_5numpy_float64_t __pyx_v_val2; + __pyx_t_5numpy_float64_t __pyx_v_intersection; + __pyx_t_5numpy_float64_t __pyx_v_union; + int __pyx_v_ival1; + int __pyx_v_ival2; __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nans1; + __Pyx_Buffer __pyx_pybuffer_nans1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nans2; + __Pyx_Buffer __pyx_pybuffer_nans2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nonzeros1; + __Pyx_Buffer __pyx_pybuffer_nonzeros1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nonzeros2; + __Pyx_Buffer __pyx_pybuffer_nonzeros2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_ps; + __Pyx_Buffer __pyx_pybuffer_ps; __Pyx_LocalBuf_ND __pyx_pybuffernd_x1; __Pyx_Buffer __pyx_pybuffer_x1; __Pyx_LocalBuf_ND __pyx_pybuffernd_x2; __Pyx_Buffer __pyx_pybuffer_x2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; - int __pyx_t_5; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } }; - int __pyx_t_10; + __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_8; + int __pyx_t_9; + Py_ssize_t __pyx_t_10; int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; @@ -8939,10 +7413,34 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU Py_ssize_t __pyx_t_25; Py_ssize_t __pyx_t_26; Py_ssize_t __pyx_t_27; - int __pyx_t_28; + Py_ssize_t __pyx_t_28; Py_ssize_t __pyx_t_29; Py_ssize_t __pyx_t_30; + Py_ssize_t __pyx_t_31; + Py_ssize_t __pyx_t_32; + Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + Py_ssize_t __pyx_t_42; + Py_ssize_t __pyx_t_43; + Py_ssize_t __pyx_t_44; + Py_ssize_t __pyx_t_45; + Py_ssize_t __pyx_t_46; __Pyx_RefNannySetupContext("jaccard_rows", 0); + __pyx_pybuffer_nonzeros1.pybuffer.buf = NULL; + __pyx_pybuffer_nonzeros1.refcount = 0; + __pyx_pybuffernd_nonzeros1.data = NULL; + __pyx_pybuffernd_nonzeros1.rcbuffer = &__pyx_pybuffer_nonzeros1; + __pyx_pybuffer_nonzeros2.pybuffer.buf = NULL; + __pyx_pybuffer_nonzeros2.refcount = 0; + __pyx_pybuffernd_nonzeros2.data = NULL; + __pyx_pybuffernd_nonzeros2.rcbuffer = &__pyx_pybuffer_nonzeros2; __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; __pyx_pybuffernd_x1.data = NULL; @@ -8951,494 +7449,791 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU __pyx_pybuffer_x2.refcount = 0; __pyx_pybuffernd_x2.data = NULL; __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; + __pyx_pybuffer_nans1.pybuffer.buf = NULL; + __pyx_pybuffer_nans1.refcount = 0; + __pyx_pybuffernd_nans1.data = NULL; + __pyx_pybuffernd_nans1.rcbuffer = &__pyx_pybuffer_nans1; + __pyx_pybuffer_nans2.pybuffer.buf = NULL; + __pyx_pybuffer_nans2.refcount = 0; + __pyx_pybuffernd_nans2.data = NULL; + __pyx_pybuffernd_nans2.rcbuffer = &__pyx_pybuffer_nans2; + __pyx_pybuffer_ps.pybuffer.buf = NULL; + __pyx_pybuffer_ps.refcount = 0; + __pyx_pybuffernd_ps.data = NULL; + __pyx_pybuffernd_ps.rcbuffer = &__pyx_pybuffer_ps; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_pybuffernd_nonzeros1.diminfo[0].strides = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros1.diminfo[0].shape = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros1.diminfo[1].strides = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros1.diminfo[1].shape = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 467, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_pybuffernd_nonzeros2.diminfo[0].strides = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros2.diminfo[0].shape = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros2.diminfo[1].strides = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros2.diminfo[1].shape = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 467, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_pybuffernd_nans1.diminfo[0].strides = __pyx_pybuffernd_nans1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans1.diminfo[0].shape = __pyx_pybuffernd_nans1.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_pybuffernd_nans2.diminfo[0].strides = __pyx_pybuffernd_nans2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans2.diminfo[0].shape = __pyx_pybuffernd_nans2.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_pybuffernd_ps.diminfo[0].strides = __pyx_pybuffernd_ps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ps.diminfo[0].shape = __pyx_pybuffernd_ps.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":472 - * fit_params): - * cdef: - * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< - * - * int n_rows1, n_rows2, n_cols, row1, row2, col - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 472, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ps = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":479 + /* "Orange/distance/_distance.pyx":363 * double [:, :] distances * - * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< + * n_rows1, n_cols = x1.shape[0], x2.shape[1] # <<<<<<<<<<<<<< * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == ps.shape[0] + * distances = np.zeros((n_rows1, n_rows2), dtype=float) */ - __pyx_t_3 = (__pyx_v_x1->dimensions[0]); - __pyx_t_4 = (__pyx_v_x1->dimensions[1]); - __pyx_v_n_rows1 = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_t_1 = (__pyx_v_x1->dimensions[0]); + __pyx_t_2 = (__pyx_v_x2->dimensions[1]); + __pyx_v_n_rows1 = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":480 + /* "Orange/distance/_distance.pyx":364 * - * n_rows1, n_cols = x1.shape[0], x1.shape[1] + * n_rows1, n_cols = x1.shape[0], x2.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< - * assert n_cols == x2.shape[1] == ps.shape[0] - * + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":481 - * n_rows1, n_cols = x1.shape[0], x1.shape[1] + /* "Orange/distance/_distance.pyx":365 + * n_rows1, n_cols = x1.shape[0], x2.shape[1] * n_rows2 = x2.shape[0] - * assert n_cols == x2.shape[1] == ps.shape[0] # <<<<<<<<<<<<<< - * - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - __pyx_t_5 = (__pyx_v_n_cols == (__pyx_v_x2->dimensions[1])); - if (__pyx_t_5) { - __pyx_t_5 = ((__pyx_v_x2->dimensions[1]) == (__pyx_v_ps.shape[0])); - } - if (unlikely(!(__pyx_t_5 != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(0, 481, __pyx_L1_error) - } - } - #endif - - /* "Orange/distance/_distance.pyx":483 - * assert n_cols == x2.shape[1] == ps.shape[0] - * * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 483, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 483, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_9; - __pyx_t_9.memview = NULL; - __pyx_t_9.data = NULL; + __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_distances = __pyx_t_7; + __pyx_t_7.memview = NULL; + __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":484 - * + /* "Orange/distance/_distance.pyx":366 + * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): + * if nans1[row1]: + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + /* "Orange/distance/_distance.pyx":367 + * distances = np.zeros((n_rows1, n_rows2), dtype=float) + * with nogil: + * for row1 in range(n_rows1): # <<<<<<<<<<<<<< + * if nans1[row1]: + * for row2 in range(n_rows2 if two_tables else row1): + */ + __pyx_t_8 = __pyx_v_n_rows1; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_row1 = __pyx_t_9; + + /* "Orange/distance/_distance.pyx":368 + * with nogil: + * for row1 in range(n_rows1): + * if nans1[row1]: # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * union = intersection = 0 + */ + __pyx_t_10 = __pyx_v_row1; + __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans1.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_nans1.diminfo[0].strides)) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":369 + * for row1 in range(n_rows1): + * if nans1[row1]: + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * union = intersection = 0 + * for col in range(n_cols): + */ + if ((__pyx_v_two_tables != 0)) { + __pyx_t_12 = __pyx_v_n_rows2; + } else { + __pyx_t_12 = __pyx_v_row1; + } + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row2 = __pyx_t_13; + + /* "Orange/distance/_distance.pyx":370 + * if nans1[row1]: + * for row2 in range(n_rows2 if two_tables else row1): + * union = intersection = 0 # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + */ + __pyx_v_union = 0.0; + __pyx_v_intersection = 0.0; + + /* "Orange/distance/_distance.pyx":371 + * for row2 in range(n_rows2 if two_tables else row1): + * union = intersection = 0 + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + */ + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":372 + * union = intersection = 0 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): + */ + __pyx_t_16 = __pyx_v_row1; + __pyx_t_17 = __pyx_v_col; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row2; + __pyx_t_20 = __pyx_v_col; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; + + /* "Orange/distance/_distance.pyx":373 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + */ + __pyx_t_11 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":374 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + */ + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":375 + * if npy_isnan(val1): + * if npy_isnan(val2): + * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + */ + __pyx_t_22 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + pow((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_ps.diminfo[0].strides)), 2.0)); + + /* "Orange/distance/_distance.pyx":376 + * if npy_isnan(val2): + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< + * elif val2 != 0: + * intersection += ps[col] + */ + __pyx_t_23 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_ps.diminfo[0].strides))), 2.0))); + + /* "Orange/distance/_distance.pyx":374 + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":377 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 + */ + __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":378 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: + * intersection += ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: + */ + __pyx_t_24 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_ps.diminfo[0].strides))); + + /* "Orange/distance/_distance.pyx":379 + * elif val2 != 0: + * intersection += ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { + __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":485 - * distances = np.zeros((n_rows1, n_rows2), dtype=float) - * with nogil: - * for row1 in range(n_rows1): # <<<<<<<<<<<<<< - * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 + /* "Orange/distance/_distance.pyx":377 + * intersection += ps[col] ** 2 + * union += 1 - (1 - ps[col]) ** 2 + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += ps[col] + * union += 1 */ - __pyx_t_10 = __pyx_v_n_rows1; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { - __pyx_v_row1 = __pyx_t_11; + goto __pyx_L14; + } - /* "Orange/distance/_distance.pyx":486 - * with nogil: - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< - * intersection = union = 0 - * for col in range(n_cols): + /* "Orange/distance/_distance.pyx":381 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: */ - if ((__pyx_v_two_tables != 0)) { - __pyx_t_12 = __pyx_v_n_rows2; - } else { - __pyx_t_12 = __pyx_v_row1; - } - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { - __pyx_v_row2 = __pyx_t_13; + /*else*/ { + __pyx_t_25 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_ps.diminfo[0].strides))); + } + __pyx_L14:; - /* "Orange/distance/_distance.pyx":487 - * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 # <<<<<<<<<<<<<< - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] + /* "Orange/distance/_distance.pyx":373 + * for col in range(n_cols): + * val1, val2 = x1[row1, col], x2[row2, col] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] ** 2 */ - __pyx_v_intersection = 0.0; - __pyx_v_union = 0.0; + goto __pyx_L13; + } - /* "Orange/distance/_distance.pyx":488 - * for row2 in range(n_rows2 if two_tables else row1): - * intersection = union = 0 - * for col in range(n_cols): # <<<<<<<<<<<<<< - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":382 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += val1 * ps[col] */ - __pyx_t_14 = __pyx_v_n_cols; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v_col = __pyx_t_15; + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":489 - * intersection = union = 0 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + /* "Orange/distance/_distance.pyx":383 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += val1 * ps[col] + * union += 1 */ - __pyx_t_16 = __pyx_v_row1; - __pyx_t_17 = __pyx_v_col; - __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[1].strides)); - __pyx_t_19 = __pyx_v_row2; - __pyx_t_20 = __pyx_v_col; - __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_18; - __pyx_v_val2 = __pyx_t_21; + __pyx_t_11 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":490 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 + /* "Orange/distance/_distance.pyx":384 + * elif npy_isnan(val2): + * if val1 != 0: + * intersection += val1 * ps[col] # <<<<<<<<<<<<<< + * union += 1 + * else: */ - __pyx_t_5 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_5) { + __pyx_t_26 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (__pyx_v_val1 * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ps.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":491 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 + /* "Orange/distance/_distance.pyx":385 + * if val1 != 0: + * intersection += val1 * ps[col] + * union += 1 # <<<<<<<<<<<<<< + * else: + * union += ps[col] */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":492 - * if npy_isnan(val1): - * if npy_isnan(val2): - * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":383 + * union += ps[col] + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * intersection += val1 * ps[col] + * union += 1 */ - __pyx_t_22 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + pow((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_22 * __pyx_v_ps.strides[0]) ))), 2.0)); + goto __pyx_L15; + } - /* "Orange/distance/_distance.pyx":493 - * if npy_isnan(val2): - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< - * elif val2 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":387 + * union += 1 + * else: + * union += ps[col] # <<<<<<<<<<<<<< + * else: + * ival1 = nonzeros1[row1, col] */ - __pyx_t_23 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) )))), 2.0))); + /*else*/ { + __pyx_t_27 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_ps.diminfo[0].strides))); + } + __pyx_L15:; - /* "Orange/distance/_distance.pyx":491 - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 + /* "Orange/distance/_distance.pyx":382 + * else: + * union += ps[col] + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * intersection += val1 * ps[col] */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":494 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 - */ - __pyx_t_5 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_5) { - - /* "Orange/distance/_distance.pyx":495 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 + /* "Orange/distance/_distance.pyx":389 + * union += ps[col] * else: + * ival1 = nonzeros1[row1, col] # <<<<<<<<<<<<<< + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 */ - __pyx_t_24 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) )))); + /*else*/ { + __pyx_t_28 = __pyx_v_row1; + __pyx_t_29 = __pyx_v_col; + __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":496 - * elif val2 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":390 * else: - * union += ps[col] + * ival1 = nonzeros1[row1, col] + * ival2 = nonzeros2[row2, col] # <<<<<<<<<<<<<< + * union += ival1 | ival2 + * intersection += ival1 & ival2 */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_30 = __pyx_v_row2; + __pyx_t_31 = __pyx_v_col; + __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_nonzeros2.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_nonzeros2.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":494 - * intersection += ps[col] ** 2 - * union += 1 - (1 - ps[col]) ** 2 - * elif val2 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":391 + * ival1 = nonzeros1[row1, col] + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 # <<<<<<<<<<<<<< + * intersection += ival1 & ival2 + * if union != 0: */ - goto __pyx_L13; - } + __pyx_v_union = (__pyx_v_union + (__pyx_v_ival1 | __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":498 - * union += 1 - * else: - * union += ps[col] # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: + /* "Orange/distance/_distance.pyx":392 + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 + * intersection += ival1 & ival2 # <<<<<<<<<<<<<< + * if union != 0: + * distances[row1, row2] = 1 - intersection / union */ - /*else*/ { - __pyx_t_25 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) )))); + __pyx_v_intersection = (__pyx_v_intersection + (__pyx_v_ival1 & __pyx_v_ival2)); } __pyx_L13:; + } - /* "Orange/distance/_distance.pyx":490 - * for col in range(n_cols): - * val1, val2 = x1[row1, col], x2[row2, col] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * intersection += ps[col] ** 2 + /* "Orange/distance/_distance.pyx":393 + * union += ival1 | ival2 + * intersection += ival1 & ival2 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * else: + */ + __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":394 + * intersection += ival1 & ival2 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< + * else: + * for row2 in range(n_rows2 if two_tables else row1): + */ + __pyx_t_32 = __pyx_v_row1; + __pyx_t_33 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + + /* "Orange/distance/_distance.pyx":393 + * union += ival1 | ival2 + * intersection += ival1 & ival2 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * else: */ - goto __pyx_L12; } + } - /* "Orange/distance/_distance.pyx":499 - * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":368 + * with nogil: + * for row1 in range(n_rows1): + * if nans1[row1]: # <<<<<<<<<<<<<< + * for row2 in range(n_rows2 if two_tables else row1): + * union = intersection = 0 */ - __pyx_t_5 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_5) { + goto __pyx_L8; + } - /* "Orange/distance/_distance.pyx":500 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":396 + * distances[row1, row2] = 1 - intersection / union + * else: + * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< + * union = intersection = 0 + * # This case is slightly different since val1 can't be nan */ - __pyx_t_5 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_5) { + /*else*/ { + if ((__pyx_v_two_tables != 0)) { + __pyx_t_12 = __pyx_v_n_rows2; + } else { + __pyx_t_12 = __pyx_v_row1; + } + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":501 - * elif npy_isnan(val2): - * if val1 != 0: - * intersection += ps[col] # <<<<<<<<<<<<<< - * union += 1 - * else: + /* "Orange/distance/_distance.pyx":397 + * else: + * for row2 in range(n_rows2 if two_tables else row1): + * union = intersection = 0 # <<<<<<<<<<<<<< + * # This case is slightly different since val1 can't be nan + * if nans2[row2]: + */ + __pyx_v_union = 0.0; + __pyx_v_intersection = 0.0; + + /* "Orange/distance/_distance.pyx":399 + * union = intersection = 0 + * # This case is slightly different since val1 can't be nan + * if nans2[row2]: # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val2 = x2[row2, col] + */ + __pyx_t_34 = __pyx_v_row2; + __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans2.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_nans2.diminfo[0].strides)) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":400 + * # This case is slightly different since val1 can't be nan + * if nans2[row2]: + * for col in range(n_cols): # <<<<<<<<<<<<<< + * val2 = x2[row2, col] + * if nonzeros1[row1, col] != 0: + */ + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":401 + * if nans2[row2]: + * for col in range(n_cols): + * val2 = x2[row2, col] # <<<<<<<<<<<<<< + * if nonzeros1[row1, col] != 0: + * union += 1 + */ + __pyx_t_35 = __pyx_v_row2; + __pyx_t_36 = __pyx_v_col; + __pyx_v_val2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_x2.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":402 + * for col in range(n_cols): + * val2 = x2[row2, col] + * if nonzeros1[row1, col] != 0: # <<<<<<<<<<<<<< + * union += 1 + * if npy_isnan(val2): */ - __pyx_t_26 = __pyx_v_col; - __pyx_v_intersection = (__pyx_v_intersection + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))); + __pyx_t_37 = __pyx_v_row1; + __pyx_t_38 = __pyx_v_col; + __pyx_t_11 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)) != 0) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":403 + * val2 = x2[row2, col] + * if nonzeros1[row1, col] != 0: + * union += 1 # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * intersection += ps[col] + */ + __pyx_v_union = (__pyx_v_union + 1.0); + + /* "Orange/distance/_distance.pyx":404 + * if nonzeros1[row1, col] != 0: + * union += 1 + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] + * elif val2 != 0: + */ + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":405 + * union += 1 + * if npy_isnan(val2): + * intersection += ps[col] # <<<<<<<<<<<<<< + * elif val2 != 0: + * intersection += 1 + */ + __pyx_t_39 = __pyx_v_col; + __pyx_v_intersection = (__pyx_v_intersection + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_ps.diminfo[0].strides))); + + /* "Orange/distance/_distance.pyx":404 + * if nonzeros1[row1, col] != 0: + * union += 1 + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * intersection += ps[col] + * elif val2 != 0: + */ + goto __pyx_L23; + } - /* "Orange/distance/_distance.pyx":502 - * if val1 != 0: - * intersection += ps[col] - * union += 1 # <<<<<<<<<<<<<< - * else: - * union += ps[col] + /* "Orange/distance/_distance.pyx":406 + * if npy_isnan(val2): + * intersection += ps[col] + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * elif npy_isnan(val2): */ - __pyx_v_union = (__pyx_v_union + 1.0); + __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":500 - * union += ps[col] - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * intersection += ps[col] - * union += 1 + /* "Orange/distance/_distance.pyx":407 + * intersection += ps[col] + * elif val2 != 0: + * intersection += 1 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * union += ps[col] */ - goto __pyx_L14; - } + __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":504 - * union += 1 - * else: - * union += ps[col] # <<<<<<<<<<<<<< - * else: - * if val1 != 0 and val2 != 0: + /* "Orange/distance/_distance.pyx":406 + * if npy_isnan(val2): + * intersection += ps[col] + * elif val2 != 0: # <<<<<<<<<<<<<< + * intersection += 1 + * elif npy_isnan(val2): */ - /*else*/ { - __pyx_t_27 = __pyx_v_col; - __pyx_v_union = (__pyx_v_union + (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) )))); - } - __pyx_L14:; + } + __pyx_L23:; - /* "Orange/distance/_distance.pyx":499 - * else: - * union += ps[col] - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * intersection += ps[col] + /* "Orange/distance/_distance.pyx":402 + * for col in range(n_cols): + * val2 = x2[row2, col] + * if nonzeros1[row1, col] != 0: # <<<<<<<<<<<<<< + * union += 1 + * if npy_isnan(val2): */ - goto __pyx_L12; - } + goto __pyx_L22; + } + + /* "Orange/distance/_distance.pyx":408 + * elif val2 != 0: + * intersection += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * union += ps[col] + * elif val2 != 0: + */ + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":409 + * intersection += 1 + * elif npy_isnan(val2): + * union += ps[col] # <<<<<<<<<<<<<< + * elif val2 != 0: + * union += 1 + */ + __pyx_t_40 = __pyx_v_col; + __pyx_v_union = (__pyx_v_union + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_ps.diminfo[0].strides))); + + /* "Orange/distance/_distance.pyx":408 + * elif val2 != 0: + * intersection += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * union += ps[col] + * elif val2 != 0: + */ + goto __pyx_L22; + } - /* "Orange/distance/_distance.pyx":506 - * union += ps[col] + /* "Orange/distance/_distance.pyx":410 + * elif npy_isnan(val2): + * union += ps[col] + * elif val2 != 0: # <<<<<<<<<<<<<< + * union += 1 * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: */ - /*else*/ { - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_28) { - } else { - __pyx_t_5 = __pyx_t_28; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_28; - __pyx_L16_bool_binop_done:; - if (__pyx_t_5) { + __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":507 + /* "Orange/distance/_distance.pyx":411 + * union += ps[col] + * elif val2 != 0: + * union += 1 # <<<<<<<<<<<<<< * else: - * if val1 != 0 and val2 != 0: - * intersection += 1 # <<<<<<<<<<<<<< - * if val1 != 0 or val2 != 0: - * union += 1 + * for col in range(n_cols): */ - __pyx_v_intersection = (__pyx_v_intersection + 1.0); + __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":506 - * union += ps[col] + /* "Orange/distance/_distance.pyx":410 + * elif npy_isnan(val2): + * union += ps[col] + * elif val2 != 0: # <<<<<<<<<<<<<< + * union += 1 * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * intersection += 1 - * if val1 != 0 or val2 != 0: */ + } + __pyx_L22:; } - /* "Orange/distance/_distance.pyx":508 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":399 + * union = intersection = 0 + * # This case is slightly different since val1 can't be nan + * if nans2[row2]: # <<<<<<<<<<<<<< + * for col in range(n_cols): + * val2 = x2[row2, col] */ - __pyx_t_28 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_28) { - } else { - __pyx_t_5 = __pyx_t_28; - goto __pyx_L19_bool_binop_done; - } - __pyx_t_28 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_5 = __pyx_t_28; - __pyx_L19_bool_binop_done:; - if (__pyx_t_5) { + goto __pyx_L19; + } - /* "Orange/distance/_distance.pyx":509 - * intersection += 1 - * if val1 != 0 or val2 != 0: - * union += 1 # <<<<<<<<<<<<<< - * if union != 0: - * distances[row1, row2] = 1 - intersection / union + /* "Orange/distance/_distance.pyx":413 + * union += 1 + * else: + * for col in range(n_cols): # <<<<<<<<<<<<<< + * ival1 = nonzeros1[row1, col] + * ival2 = nonzeros2[row2, col] */ - __pyx_v_union = (__pyx_v_union + 1.0); + /*else*/ { + __pyx_t_14 = __pyx_v_n_cols; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":508 - * if val1 != 0 and val2 != 0: - * intersection += 1 - * if val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * union += 1 - * if union != 0: + /* "Orange/distance/_distance.pyx":414 + * else: + * for col in range(n_cols): + * ival1 = nonzeros1[row1, col] # <<<<<<<<<<<<<< + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 */ + __pyx_t_41 = __pyx_v_row1; + __pyx_t_42 = __pyx_v_col; + __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":415 + * for col in range(n_cols): + * ival1 = nonzeros1[row1, col] + * ival2 = nonzeros2[row2, col] # <<<<<<<<<<<<<< + * union += ival1 | ival2 + * intersection += ival1 & ival2 + */ + __pyx_t_43 = __pyx_v_row2; + __pyx_t_44 = __pyx_v_col; + __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_nonzeros2.diminfo[0].strides, __pyx_t_44, __pyx_pybuffernd_nonzeros2.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":416 + * ival1 = nonzeros1[row1, col] + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 # <<<<<<<<<<<<<< + * intersection += ival1 & ival2 + * if union != 0: + */ + __pyx_v_union = (__pyx_v_union + (__pyx_v_ival1 | __pyx_v_ival2)); + + /* "Orange/distance/_distance.pyx":417 + * ival2 = nonzeros2[row2, col] + * union += ival1 | ival2 + * intersection += ival1 & ival2 # <<<<<<<<<<<<<< + * if union != 0: + * distances[row1, row2] = 1 - intersection / union + */ + __pyx_v_intersection = (__pyx_v_intersection + (__pyx_v_ival1 & __pyx_v_ival2)); } } - __pyx_L12:; - } + __pyx_L19:; - /* "Orange/distance/_distance.pyx":510 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":418 + * union += ival1 | ival2 + * intersection += ival1 & ival2 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * if not two_tables: */ - __pyx_t_5 = ((__pyx_v_union != 0.0) != 0); - if (__pyx_t_5) { + __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":511 - * union += 1 - * if union != 0: - * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< - * + /* "Orange/distance/_distance.pyx":419 + * intersection += ival1 & ival2 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< * if not two_tables: + * _lower_to_symmetric(distances) */ - __pyx_t_29 = __pyx_v_row1; - __pyx_t_30 = __pyx_v_row2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_29 * __pyx_v_distances.strides[0]) ) + __pyx_t_30 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + __pyx_t_45 = __pyx_v_row1; + __pyx_t_46 = __pyx_v_row2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_45 * __pyx_v_distances.strides[0]) ) + __pyx_t_46 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":510 - * if val1 != 0 or val2 != 0: - * union += 1 - * if union != 0: # <<<<<<<<<<<<<< - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":418 + * union += ival1 | ival2 + * intersection += ival1 & ival2 + * if union != 0: # <<<<<<<<<<<<<< + * distances[row1, row2] = 1 - intersection / union + * if not two_tables: */ + } } } + __pyx_L8:; } } - /* "Orange/distance/_distance.pyx":484 - * + /* "Orange/distance/_distance.pyx":366 + * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for row1 in range(n_rows1): - * for row2 in range(n_rows2 if two_tables else row1): + * if nans1[row1]: */ /*finally:*/ { /*normal exit:*/{ @@ -9451,18 +8246,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":513 - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":420 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ - __pyx_t_5 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_5) { + __pyx_t_11 = ((!(__pyx_v_two_tables != 0)) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":514 - * + /* "Orange/distance/_distance.pyx":421 + * distances[row1, row2] = 1 - intersection / union * if not two_tables: * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances @@ -9470,16 +8265,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU */ __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); - /* "Orange/distance/_distance.pyx":513 - * distances[row1, row2] = 1 - intersection / union - * + /* "Orange/distance/_distance.pyx":420 + * if union != 0: + * distances[row1, row2] = 1 - intersection / union * if not two_tables: # <<<<<<<<<<<<<< * _lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":515 + /* "Orange/distance/_distance.pyx":422 * if not two_tables: * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< @@ -9487,32 +8282,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":349 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< + * np.ndarray[np.int8_t, ndim=2] nonzeros2, + * np.ndarray[np.float64_t, ndim=2] x1, */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ps.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} @@ -9520,41 +8319,49 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20jaccard_rows(CYTHON_UNU __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ps.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "Orange/distance/_distance.pyx":518 +/* "Orange/distance/_distance.pyx":425 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x, + * np.ndarray[np.int8_t, ndim=1] nans, */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_22jaccard_cols[] = "jaccard_cols(ndarray x, fit_params)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_23jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_22jaccard_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_24jaccard_cols[] = "jaccard_cols(ndarray nonzeros, ndarray x, ndarray nans, ndarray ps)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_25jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_24jaccard_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_nonzeros = 0; PyArrayObject *__pyx_v_x = 0; - PyObject *__pyx_v_fit_params = 0; + PyArrayObject *__pyx_v_nans = 0; + PyArrayObject *__pyx_v_ps = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("jaccard_cols (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_fit_params,0}; - PyObject* values[2] = {0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nonzeros,&__pyx_n_s_x,&__pyx_n_s_nans,&__pyx_n_s_ps,0}; + PyObject* values[4] = {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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -9563,36 +8370,53 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject * kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fit_params)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 1); __PYX_ERR(0, 425, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 2); __PYX_ERR(0, 425, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ps)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, 1); __PYX_ERR(0, 518, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 3); __PYX_ERR(0, 425, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 518, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 425, __pyx_L3_error) } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); } - __pyx_v_x = ((PyArrayObject *)values[0]); - __pyx_v_fit_params = values[1]; + __pyx_v_nonzeros = ((PyArrayObject *)values[0]); + __pyx_v_x = ((PyArrayObject *)values[1]); + __pyx_v_nans = ((PyArrayObject *)values[2]); + __pyx_v_ps = ((PyArrayObject *)values[3]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 518, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 425, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 518, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(__pyx_self, __pyx_v_x, __pyx_v_fit_params); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros), __pyx_ptype_5numpy_ndarray, 1, "nonzeros", 0))) __PYX_ERR(0, 425, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 426, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans), __pyx_ptype_5numpy_ndarray, 1, "nans", 0))) __PYX_ERR(0, 427, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 428, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(__pyx_self, __pyx_v_nonzeros, __pyx_v_x, __pyx_v_nans, __pyx_v_ps); /* function exit code */ goto __pyx_L0; @@ -9603,8 +8427,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_cols(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyObject *__pyx_v_fit_params) { - __Pyx_memviewslice __pyx_v_ps = { 0, 0, { 0 }, { 0 }, { 0 } }; +static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -9612,40 +8435,50 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNU int __pyx_v_row; double __pyx_v_val1; double __pyx_v_val2; + double __pyx_v_intersection; + double __pyx_v_union; + __pyx_t_5numpy_int8_t __pyx_v_ival1; + __pyx_t_5numpy_int8_t __pyx_v_ival2; int __pyx_v_in_both; - int __pyx_v_in_one; + int __pyx_v_in_any; int __pyx_v_in1_unk2; int __pyx_v_unk1_in2; int __pyx_v_unk1_unk2; int __pyx_v_unk1_not2; int __pyx_v_not1_unk2; __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nans; + __Pyx_Buffer __pyx_pybuffer_nans; + __Pyx_LocalBuf_ND __pyx_pybuffernd_nonzeros; + __Pyx_Buffer __pyx_pybuffer_nonzeros; + __Pyx_LocalBuf_ND __pyx_pybuffernd_ps; + __Pyx_Buffer __pyx_pybuffer_ps; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } }; - npy_intp __pyx_t_3; - npy_intp __pyx_t_4; + npy_intp __pyx_t_1; + npy_intp __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_t_8; int __pyx_t_9; - int __pyx_t_10; + Py_ssize_t __pyx_t_10; int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; int __pyx_t_14; - Py_ssize_t __pyx_t_15; + int __pyx_t_15; Py_ssize_t __pyx_t_16; - __pyx_t_5numpy_float64_t __pyx_t_17; - Py_ssize_t __pyx_t_18; + Py_ssize_t __pyx_t_17; + __pyx_t_5numpy_float64_t __pyx_t_18; Py_ssize_t __pyx_t_19; - __pyx_t_5numpy_float64_t __pyx_t_20; - int __pyx_t_21; - int __pyx_t_22; + Py_ssize_t __pyx_t_20; + __pyx_t_5numpy_float64_t __pyx_t_21; + Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; Py_ssize_t __pyx_t_24; Py_ssize_t __pyx_t_25; @@ -9654,100 +8487,141 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNU Py_ssize_t __pyx_t_28; Py_ssize_t __pyx_t_29; Py_ssize_t __pyx_t_30; - double __pyx_t_31; + Py_ssize_t __pyx_t_31; Py_ssize_t __pyx_t_32; Py_ssize_t __pyx_t_33; - Py_ssize_t __pyx_t_34; + double __pyx_t_34; Py_ssize_t __pyx_t_35; + Py_ssize_t __pyx_t_36; + Py_ssize_t __pyx_t_37; + Py_ssize_t __pyx_t_38; + Py_ssize_t __pyx_t_39; + Py_ssize_t __pyx_t_40; + Py_ssize_t __pyx_t_41; + Py_ssize_t __pyx_t_42; + Py_ssize_t __pyx_t_43; + Py_ssize_t __pyx_t_44; + Py_ssize_t __pyx_t_45; + Py_ssize_t __pyx_t_46; + Py_ssize_t __pyx_t_47; + Py_ssize_t __pyx_t_48; + Py_ssize_t __pyx_t_49; + Py_ssize_t __pyx_t_50; + Py_ssize_t __pyx_t_51; + Py_ssize_t __pyx_t_52; + Py_ssize_t __pyx_t_53; + Py_ssize_t __pyx_t_54; + Py_ssize_t __pyx_t_55; + Py_ssize_t __pyx_t_56; + Py_ssize_t __pyx_t_57; + Py_ssize_t __pyx_t_58; + Py_ssize_t __pyx_t_59; + Py_ssize_t __pyx_t_60; + Py_ssize_t __pyx_t_61; + Py_ssize_t __pyx_t_62; + Py_ssize_t __pyx_t_63; + Py_ssize_t __pyx_t_64; + Py_ssize_t __pyx_t_65; __Pyx_RefNannySetupContext("jaccard_cols", 0); + __pyx_pybuffer_nonzeros.pybuffer.buf = NULL; + __pyx_pybuffer_nonzeros.refcount = 0; + __pyx_pybuffernd_nonzeros.data = NULL; + __pyx_pybuffernd_nonzeros.rcbuffer = &__pyx_pybuffer_nonzeros; __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; + __pyx_pybuffer_nans.pybuffer.buf = NULL; + __pyx_pybuffer_nans.refcount = 0; + __pyx_pybuffernd_nans.data = NULL; + __pyx_pybuffernd_nans.rcbuffer = &__pyx_pybuffer_nans; + __pyx_pybuffer_ps.pybuffer.buf = NULL; + __pyx_pybuffer_ps.refcount = 0; + __pyx_pybuffernd_ps.data = NULL; + __pyx_pybuffernd_ps.rcbuffer = &__pyx_pybuffer_ps; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + } + __pyx_pybuffernd_nonzeros.diminfo[0].strides = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros.diminfo[0].shape = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros.diminfo[1].strides = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros.diminfo[1].shape = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 518, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + } + __pyx_pybuffernd_nans.diminfo[0].strides = __pyx_pybuffernd_nans.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans.diminfo[0].shape = __pyx_pybuffernd_nans.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + } + __pyx_pybuffernd_ps.diminfo[0].strides = __pyx_pybuffernd_ps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ps.diminfo[0].shape = __pyx_pybuffernd_ps.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":520 - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - * cdef: - * double [:] ps = fit_params["ps"] # <<<<<<<<<<<<<< - * - * int n_rows, n_cols, col1, col2, row - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fit_params, __pyx_n_s_ps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1); - if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 520, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ps = __pyx_t_2; - __pyx_t_2.memview = NULL; - __pyx_t_2.data = NULL; - - /* "Orange/distance/_distance.pyx":527 + /* "Orange/distance/_distance.pyx":436 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: */ - __pyx_t_3 = (__pyx_v_x->dimensions[0]); - __pyx_t_4 = (__pyx_v_x->dimensions[1]); - __pyx_v_n_rows = __pyx_t_3; - __pyx_v_n_cols = __pyx_t_4; + __pyx_t_1 = (__pyx_v_x->dimensions[0]); + __pyx_t_2 = (__pyx_v_x->dimensions[1]); + __pyx_v_n_rows = __pyx_t_1; + __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":528 + /* "Orange/distance/_distance.pyx":437 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); - __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 528, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1); - if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 528, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_distances = __pyx_t_8; - __pyx_t_8.memview = NULL; - __pyx_t_8.data = NULL; + __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 437, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_distances = __pyx_t_7; + __pyx_t_7.memview = NULL; + __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":529 + /* "Orange/distance/_distance.pyx":438 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for col1 in range(n_cols): - * for col2 in range(col1): + * if nans[col1]: */ { #ifdef WITH_THREAD @@ -9756,394 +8630,783 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNU #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":530 + /* "Orange/distance/_distance.pyx":439 * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< - * for col2 in range(col1): - * in_both = in_one = 0 + * if nans[col1]: + * for col2 in range(col1): */ - __pyx_t_9 = __pyx_v_n_cols; - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { - __pyx_v_col1 = __pyx_t_10; + __pyx_t_8 = __pyx_v_n_cols; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_col1 = __pyx_t_9; - /* "Orange/distance/_distance.pyx":531 + /* "Orange/distance/_distance.pyx":440 * with nogil: * for col1 in range(n_cols): - * for col2 in range(col1): # <<<<<<<<<<<<<< - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * if nans[col1]: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * in_both = in_any = 0 */ - __pyx_t_11 = __pyx_v_col1; - for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { - __pyx_v_col2 = __pyx_t_12; + __pyx_t_10 = __pyx_v_col1; + __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_nans.diminfo[0].strides)) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":532 + /* "Orange/distance/_distance.pyx":441 * for col1 in range(n_cols): - * for col2 in range(col1): - * in_both = in_one = 0 # <<<<<<<<<<<<<< - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): + * if nans[col1]: + * for col2 in range(col1): # <<<<<<<<<<<<<< + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + */ + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; + + /* "Orange/distance/_distance.pyx":442 + * if nans[col1]: + * for col2 in range(col1): + * in_both = in_any = 0 # <<<<<<<<<<<<<< + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): */ - __pyx_v_in_both = 0; - __pyx_v_in_one = 0; + __pyx_v_in_both = 0; + __pyx_v_in_any = 0; - /* "Orange/distance/_distance.pyx":533 - * for col2 in range(col1): - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] + /* "Orange/distance/_distance.pyx":443 + * for col2 in range(col1): + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] */ - __pyx_v_in1_unk2 = 0; - __pyx_v_unk1_in2 = 0; - __pyx_v_unk1_unk2 = 0; - __pyx_v_unk1_not2 = 0; - __pyx_v_not1_unk2 = 0; + __pyx_v_in1_unk2 = 0; + __pyx_v_unk1_in2 = 0; + __pyx_v_unk1_unk2 = 0; + __pyx_v_unk1_not2 = 0; + __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":534 - * in_both = in_one = 0 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): # <<<<<<<<<<<<<< - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): + /* "Orange/distance/_distance.pyx":444 + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): */ - __pyx_t_13 = __pyx_v_n_rows; - for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { - __pyx_v_row = __pyx_t_14; + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":535 - * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< - * if npy_isnan(val1): - * if npy_isnan(val2): + /* "Orange/distance/_distance.pyx":445 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val1): + * if npy_isnan(val2): */ - __pyx_t_15 = __pyx_v_row; - __pyx_t_16 = __pyx_v_col1; - __pyx_t_17 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_t_18 = __pyx_v_row; - __pyx_t_19 = __pyx_v_col2; - __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_x.diminfo[1].strides)); - __pyx_v_val1 = __pyx_t_17; - __pyx_v_val2 = __pyx_t_20; + __pyx_t_16 = __pyx_v_row; + __pyx_t_17 = __pyx_v_col1; + __pyx_t_18 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_t_19 = __pyx_v_row; + __pyx_t_20 = __pyx_v_col2; + __pyx_t_21 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x.diminfo[1].strides)); + __pyx_v_val1 = __pyx_t_18; + __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":536 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 + /* "Orange/distance/_distance.pyx":446 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ - __pyx_t_21 = (npy_isnan(__pyx_v_val1) != 0); - if (__pyx_t_21) { + __pyx_t_11 = (npy_isnan(__pyx_v_val1) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":537 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":447 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":538 - * if npy_isnan(val1): - * if npy_isnan(val2): - * unk1_unk2 += 1 # <<<<<<<<<<<<<< - * elif val2 != 0: - * unk1_in2 += 1 + /* "Orange/distance/_distance.pyx":448 + * if npy_isnan(val1): + * if npy_isnan(val2): + * unk1_unk2 += 1 # <<<<<<<<<<<<<< + * elif val2 != 0: + * unk1_in2 += 1 */ - __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); + __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":537 - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): - * if npy_isnan(val2): # <<<<<<<<<<<<<< - * unk1_unk2 += 1 - * elif val2 != 0: + /* "Orange/distance/_distance.pyx":447 + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * unk1_unk2 += 1 + * elif val2 != 0: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":449 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: + */ + __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":450 + * unk1_unk2 += 1 + * elif val2 != 0: + * unk1_in2 += 1 # <<<<<<<<<<<<<< + * else: + * unk1_not2 += 1 + */ + __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); + + /* "Orange/distance/_distance.pyx":449 + * if npy_isnan(val2): + * unk1_unk2 += 1 + * elif val2 != 0: # <<<<<<<<<<<<<< + * unk1_in2 += 1 + * else: + */ + goto __pyx_L14; + } + + /* "Orange/distance/_distance.pyx":452 + * unk1_in2 += 1 + * else: + * unk1_not2 += 1 # <<<<<<<<<<<<<< + * elif npy_isnan(val2): + * if val1 != 0: + */ + /*else*/ { + __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); + } + __pyx_L14:; + + /* "Orange/distance/_distance.pyx":446 + * for row in range(n_rows): + * val1, val2 = x[row, col1], x[row, col2] + * if npy_isnan(val1): # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * unk1_unk2 += 1 */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":539 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 - * else: + /* "Orange/distance/_distance.pyx":453 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 */ - __pyx_t_21 = ((__pyx_v_val2 != 0.0) != 0); - if (__pyx_t_21) { + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":540 - * unk1_unk2 += 1 - * elif val2 != 0: - * unk1_in2 += 1 # <<<<<<<<<<<<<< - * else: - * unk1_not2 += 1 + /* "Orange/distance/_distance.pyx":454 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: */ - __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); + __pyx_t_11 = ((__pyx_v_val1 != 0.0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":539 - * if npy_isnan(val2): - * unk1_unk2 += 1 - * elif val2 != 0: # <<<<<<<<<<<<<< - * unk1_in2 += 1 + /* "Orange/distance/_distance.pyx":455 + * elif npy_isnan(val2): + * if val1 != 0: + * in1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * not1_unk2 += 1 + */ + __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + + /* "Orange/distance/_distance.pyx":454 + * unk1_not2 += 1 + * elif npy_isnan(val2): + * if val1 != 0: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + goto __pyx_L15; + } + + /* "Orange/distance/_distance.pyx":457 + * in1_unk2 += 1 + * else: + * not1_unk2 += 1 # <<<<<<<<<<<<<< * else: + * ival1 = nonzeros[row, col1] + */ + /*else*/ { + __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); + } + __pyx_L15:; + + /* "Orange/distance/_distance.pyx":453 + * else: + * unk1_not2 += 1 + * elif npy_isnan(val2): # <<<<<<<<<<<<<< + * if val1 != 0: + * in1_unk2 += 1 */ goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":542 - * unk1_in2 += 1 + /* "Orange/distance/_distance.pyx":459 + * not1_unk2 += 1 * else: - * unk1_not2 += 1 # <<<<<<<<<<<<<< - * elif npy_isnan(val2): - * if val1 != 0: + * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 */ /*else*/ { - __pyx_v_unk1_not2 = (__pyx_v_unk1_not2 + 1); + __pyx_t_22 = __pyx_v_row; + __pyx_t_23 = __pyx_v_col1; + __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":460 + * else: + * ival1 = nonzeros[row, col1] + * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + */ + __pyx_t_24 = __pyx_v_row; + __pyx_t_25 = __pyx_v_col2; + __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":461 + * ival1 = nonzeros[row, col1] + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 # <<<<<<<<<<<<<< + * in_any += ival1 | ival2 + * union = (in_any + unk1_in2 + in1_unk2 + */ + __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); + + /* "Orange/distance/_distance.pyx":462 + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 # <<<<<<<<<<<<<< + * union = (in_any + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 + */ + __pyx_v_in_any = (__pyx_v_in_any + (__pyx_v_ival1 | __pyx_v_ival2)); } __pyx_L13:; + } - /* "Orange/distance/_distance.pyx":536 - * for row in range(n_rows): - * val1, val2 = x[row, col1], x[row, col2] - * if npy_isnan(val1): # <<<<<<<<<<<<<< - * if npy_isnan(val2): - * unk1_unk2 += 1 + /* "Orange/distance/_distance.pyx":464 + * in_any += ival1 | ival2 + * union = (in_any + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + */ + __pyx_t_26 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":465 + * union = (in_any + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * if union != 0: + */ + __pyx_t_27 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":466 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< + * if union != 0: + * intersection = (in_both + */ + __pyx_t_28 = __pyx_v_col1; + __pyx_t_29 = __pyx_v_col2; + __pyx_v_union = (((((__pyx_v_in_any + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_not2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_ps.diminfo[0].strides))) * (1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_ps.diminfo[0].strides))))) * __pyx_v_unk1_unk2)); + + /* "Orange/distance/_distance.pyx":467 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * if union != 0: # <<<<<<<<<<<<<< + * intersection = (in_both + * + ps[col1] * unk1_in2 + + */ + __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":469 + * if union != 0: + * intersection = (in_both + * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) + */ + __pyx_t_30 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":470 + * intersection = (in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) + * distances[col1, col2] = distances[col2, col1] = \ + */ + __pyx_t_31 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":471 + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - intersection / union + */ + __pyx_t_32 = __pyx_v_col1; + __pyx_t_33 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":470 + * intersection = (in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) + * distances[col1, col2] = distances[col2, col1] = \ + */ + __pyx_v_intersection = (((__pyx_v_in_both + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_in2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_in1_unk2)) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_ps.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_ps.diminfo[0].strides))) * __pyx_v_unk1_unk2)); + + /* "Orange/distance/_distance.pyx":473 + * + ps[col1] * ps[col2] * unk1_unk2) + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - intersection / union # <<<<<<<<<<<<<< + * else: + * for col2 in range(col1): + */ + __pyx_t_34 = (1.0 - (__pyx_v_intersection / __pyx_v_union)); + + /* "Orange/distance/_distance.pyx":472 + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - intersection / union + * else: + */ + __pyx_t_35 = __pyx_v_col1; + __pyx_t_36 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_35 * __pyx_v_distances.strides[0]) ) + __pyx_t_36 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; + __pyx_t_37 = __pyx_v_col2; + __pyx_t_38 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; + + /* "Orange/distance/_distance.pyx":467 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * if union != 0: # <<<<<<<<<<<<<< + * intersection = (in_both + * + ps[col1] * unk1_in2 + */ - goto __pyx_L12; } + } - /* "Orange/distance/_distance.pyx":543 - * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 + /* "Orange/distance/_distance.pyx":440 + * with nogil: + * for col1 in range(n_cols): + * if nans[col1]: # <<<<<<<<<<<<<< + * for col2 in range(col1): + * in_both = in_any = 0 */ - __pyx_t_21 = (npy_isnan(__pyx_v_val2) != 0); - if (__pyx_t_21) { + goto __pyx_L8; + } - /* "Orange/distance/_distance.pyx":544 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: + /* "Orange/distance/_distance.pyx":475 + * 1 - intersection / union + * else: + * for col2 in range(col1): # <<<<<<<<<<<<<< + * if nans[col2]: + * in_both = in_any = 0 */ - __pyx_t_21 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_21) { + /*else*/ { + __pyx_t_12 = __pyx_v_col1; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":545 - * elif npy_isnan(val2): - * if val1 != 0: - * in1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * not1_unk2 += 1 + /* "Orange/distance/_distance.pyx":476 + * else: + * for col2 in range(col1): + * if nans[col2]: # <<<<<<<<<<<<<< + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + */ + __pyx_t_39 = __pyx_v_col2; + __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_nans.diminfo[0].strides)) != 0); + if (__pyx_t_11) { + + /* "Orange/distance/_distance.pyx":477 + * for col2 in range(col1): + * if nans[col2]: + * in_both = in_any = 0 # <<<<<<<<<<<<<< + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + */ + __pyx_v_in_both = 0; + __pyx_v_in_any = 0; + + /* "Orange/distance/_distance.pyx":478 + * if nans[col2]: + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] + */ + __pyx_v_in1_unk2 = 0; + __pyx_v_unk1_in2 = 0; + __pyx_v_unk1_unk2 = 0; + __pyx_v_unk1_not2 = 0; + __pyx_v_not1_unk2 = 0; + + /* "Orange/distance/_distance.pyx":479 + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * ival1 = nonzeros[row, col1] + * val2 = x[row, col2] + */ + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":480 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< + * val2 = x[row, col2] + * if npy_isnan(val2): */ - __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + __pyx_t_40 = __pyx_v_row; + __pyx_t_41 = __pyx_v_col1; + __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":544 - * unk1_not2 += 1 - * elif npy_isnan(val2): - * if val1 != 0: # <<<<<<<<<<<<<< - * in1_unk2 += 1 - * else: + /* "Orange/distance/_distance.pyx":481 + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] + * val2 = x[row, col2] # <<<<<<<<<<<<<< + * if npy_isnan(val2): + * if ival1: */ - goto __pyx_L14; - } + __pyx_t_42 = __pyx_v_row; + __pyx_t_43 = __pyx_v_col2; + __pyx_v_val2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_x.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":547 - * in1_unk2 += 1 - * else: - * not1_unk2 += 1 # <<<<<<<<<<<<<< - * else: - * if val1 != 0 and val2 != 0: + /* "Orange/distance/_distance.pyx":482 + * ival1 = nonzeros[row, col1] + * val2 = x[row, col2] + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if ival1: + * in1_unk2 += 1 */ - /*else*/ { - __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); - } - __pyx_L14:; + __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":543 - * else: - * unk1_not2 += 1 - * elif npy_isnan(val2): # <<<<<<<<<<<<<< - * if val1 != 0: - * in1_unk2 += 1 + /* "Orange/distance/_distance.pyx":483 + * val2 = x[row, col2] + * if npy_isnan(val2): + * if ival1: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: */ - goto __pyx_L12; - } + __pyx_t_11 = (__pyx_v_ival1 != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":549 - * not1_unk2 += 1 - * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: + /* "Orange/distance/_distance.pyx":484 + * if npy_isnan(val2): + * if ival1: + * in1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * not1_unk2 += 1 */ - /*else*/ { - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L16_bool_binop_done; + __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); + + /* "Orange/distance/_distance.pyx":483 + * val2 = x[row, col2] + * if npy_isnan(val2): + * if ival1: # <<<<<<<<<<<<<< + * in1_unk2 += 1 + * else: + */ + goto __pyx_L23; + } + + /* "Orange/distance/_distance.pyx":486 + * in1_unk2 += 1 + * else: + * not1_unk2 += 1 # <<<<<<<<<<<<<< + * else: + * ival2 = nonzeros[row, col2] + */ + /*else*/ { + __pyx_v_not1_unk2 = (__pyx_v_not1_unk2 + 1); + } + __pyx_L23:; + + /* "Orange/distance/_distance.pyx":482 + * ival1 = nonzeros[row, col1] + * val2 = x[row, col2] + * if npy_isnan(val2): # <<<<<<<<<<<<<< + * if ival1: + * in1_unk2 += 1 + */ + goto __pyx_L22; + } + + /* "Orange/distance/_distance.pyx":488 + * not1_unk2 += 1 + * else: + * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + */ + /*else*/ { + __pyx_t_44 = __pyx_v_row; + __pyx_t_45 = __pyx_v_col2; + __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":489 + * else: + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 # <<<<<<<<<<<<<< + * in_any += ival1 | ival2 + * distances[col1, col2] = distances[col2, col1] = \ + */ + __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); + + /* "Orange/distance/_distance.pyx":490 + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + */ + __pyx_v_in_any = (__pyx_v_in_any + (__pyx_v_ival1 | __pyx_v_ival2)); + } + __pyx_L22:; } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L16_bool_binop_done:; - if (__pyx_t_21) { - /* "Orange/distance/_distance.pyx":550 + /* "Orange/distance/_distance.pyx":493 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both + * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ + */ + __pyx_t_46 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":494 + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_any + unk1_in2 + in1_unk2 + + */ + __pyx_t_47 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":495 + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< + * (in_any + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + */ + __pyx_t_48 = __pyx_v_col1; + __pyx_t_49 = __pyx_v_col2; + + /* "Orange/distance/_distance.pyx":497 + * + ps[col1] * ps[col2] * unk1_unk2) / \ + * (in_any + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + */ + __pyx_t_50 = __pyx_v_col1; + + /* "Orange/distance/_distance.pyx":498 + * (in_any + unk1_in2 + in1_unk2 + + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * else: - * if val1 != 0 and val2 != 0: - * in_both += 1 # <<<<<<<<<<<<<< - * elif val1 != 0 or val2 != 0: - * in_one += 1 */ - __pyx_v_in_both = (__pyx_v_in_both + 1); + __pyx_t_51 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":549 - * not1_unk2 += 1 + /* "Orange/distance/_distance.pyx":499 + * + ps[col1] * unk1_not2 + * + ps[col2] * not1_unk2 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< * else: - * if val1 != 0 and val2 != 0: # <<<<<<<<<<<<<< - * in_both += 1 - * elif val1 != 0 or val2 != 0: + * in_both = in_any = 0 */ - goto __pyx_L15; - } + __pyx_t_52 = __pyx_v_col1; + __pyx_t_53 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":551 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ + /* "Orange/distance/_distance.pyx":492 + * in_any += ival1 | ival2 + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both # <<<<<<<<<<<<<< + * + ps[col1] * unk1_in2 + + * + ps[col2] * in1_unk2 + */ - __pyx_t_22 = ((__pyx_v_val1 != 0.0) != 0); - if (!__pyx_t_22) { - } else { - __pyx_t_21 = __pyx_t_22; - goto __pyx_L18_bool_binop_done; - } - __pyx_t_22 = ((__pyx_v_val2 != 0.0) != 0); - __pyx_t_21 = __pyx_t_22; - __pyx_L18_bool_binop_done:; - if (__pyx_t_21) { - - /* "Orange/distance/_distance.pyx":552 - * in_both += 1 - * elif val1 != 0 or val2 != 0: - * in_one += 1 # <<<<<<<<<<<<<< - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - */ - __pyx_v_in_one = (__pyx_v_in_one + 1); - - /* "Orange/distance/_distance.pyx":551 - * if val1 != 0 and val2 != 0: - * in_both += 1 - * elif val1 != 0 or val2 != 0: # <<<<<<<<<<<<<< - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ + __pyx_t_21 = (1.0 - (((double)(((__pyx_v_in_both + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_in2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_in1_unk2)) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_ps.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_49, __pyx_pybuffernd_ps.diminfo[0].strides))) * __pyx_v_unk1_unk2))) / (((((__pyx_v_in_any + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_50, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_not2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_51, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_ps.diminfo[0].strides))) * (1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_53, __pyx_pybuffernd_ps.diminfo[0].strides))))) * __pyx_v_unk1_unk2)))); + + /* "Orange/distance/_distance.pyx":491 + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - float(in_both + * + ps[col1] * unk1_in2 + + */ + __pyx_t_54 = __pyx_v_col1; + __pyx_t_55 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_54 * __pyx_v_distances.strides[0]) ) + __pyx_t_55 * __pyx_v_distances.strides[1]) )) = __pyx_t_21; + __pyx_t_56 = __pyx_v_col2; + __pyx_t_57 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_56 * __pyx_v_distances.strides[0]) ) + __pyx_t_57 * __pyx_v_distances.strides[1]) )) = __pyx_t_21; + + /* "Orange/distance/_distance.pyx":476 + * else: + * for col2 in range(col1): + * if nans[col2]: # <<<<<<<<<<<<<< + * in_both = in_any = 0 + * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 */ - } - __pyx_L15:; + goto __pyx_L19; } - __pyx_L12:; - } - /* "Orange/distance/_distance.pyx":555 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both - * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ - */ - __pyx_t_23 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":556 - * 1 - float(in_both - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - */ - __pyx_t_24 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":557 - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + - * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - */ - __pyx_t_25 = __pyx_v_col1; - __pyx_t_26 = __pyx_v_col2; - - /* "Orange/distance/_distance.pyx":559 - * + ps[col1] * ps[col2] * unk1_unk2) / \ - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - */ - __pyx_t_27 = __pyx_v_col1; - - /* "Orange/distance/_distance.pyx":560 - * (in_both + in_one + unk1_in2 + in1_unk2 + - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) - * return distances + /* "Orange/distance/_distance.pyx":501 + * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + * else: + * in_both = in_any = 0 # <<<<<<<<<<<<<< + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] + */ + /*else*/ { + __pyx_v_in_both = 0; + __pyx_v_in_any = 0; + + /* "Orange/distance/_distance.pyx":502 + * else: + * in_both = in_any = 0 + * for row in range(n_rows): # <<<<<<<<<<<<<< + * ival1 = nonzeros[row, col1] + * ival2 = nonzeros[row, col2] + */ + __pyx_t_14 = __pyx_v_n_rows; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_row = __pyx_t_15; + + /* "Orange/distance/_distance.pyx":503 + * in_both = in_any = 0 + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 + */ + __pyx_t_58 = __pyx_v_row; + __pyx_t_59 = __pyx_v_col1; + __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_59, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":504 + * for row in range(n_rows): + * ival1 = nonzeros[row, col1] + * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + */ + __pyx_t_60 = __pyx_v_row; + __pyx_t_61 = __pyx_v_col2; + __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_60, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_61, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); + + /* "Orange/distance/_distance.pyx":505 + * ival1 = nonzeros[row, col1] + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 # <<<<<<<<<<<<<< + * in_any += ival1 | ival2 + * if in_any != 0: + */ + __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); + + /* "Orange/distance/_distance.pyx":506 + * ival2 = nonzeros[row, col2] + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 # <<<<<<<<<<<<<< + * if in_any != 0: + * distances[col1, col2] = distances[col2, col1] = \ */ - __pyx_t_28 = __pyx_v_col2; + __pyx_v_in_any = (__pyx_v_in_any + (__pyx_v_ival1 | __pyx_v_ival2)); + } + + /* "Orange/distance/_distance.pyx":507 + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + * if in_any != 0: # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both) / in_any + */ + __pyx_t_11 = ((__pyx_v_in_any != 0) != 0); + if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":561 - * + ps[col1] * unk1_not2 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< + /* "Orange/distance/_distance.pyx":509 + * if in_any != 0: + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both) / in_any # <<<<<<<<<<<<<< + * * return distances */ - __pyx_t_29 = __pyx_v_col1; - __pyx_t_30 = __pyx_v_col2; + __pyx_t_34 = (1.0 - (((double)__pyx_v_in_both) / __pyx_v_in_any)); - /* "Orange/distance/_distance.pyx":554 - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ - * 1 - float(in_both # <<<<<<<<<<<<<< - * + ps[col1] * unk1_in2 + - * + ps[col2] * in1_unk2 + + /* "Orange/distance/_distance.pyx":508 + * in_any += ival1 | ival2 + * if in_any != 0: + * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< + * 1 - float(in_both) / in_any + * */ - __pyx_t_31 = (1.0 - ((((__pyx_v_in_both + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_23 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_in2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_24 * __pyx_v_ps.strides[0]) ))) * __pyx_v_in1_unk2)) + (((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_25 * __pyx_v_ps.strides[0]) ))) * (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_26 * __pyx_v_ps.strides[0]) )))) * __pyx_v_unk1_unk2)) / ((((((__pyx_v_in_both + __pyx_v_in_one) + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_27 * __pyx_v_ps.strides[0]) ))) * __pyx_v_unk1_not2)) + ((*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_28 * __pyx_v_ps.strides[0]) ))) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_29 * __pyx_v_ps.strides[0]) )))) * (1.0 - (*((double *) ( /* dim=0 */ (__pyx_v_ps.data + __pyx_t_30 * __pyx_v_ps.strides[0]) )))))) * __pyx_v_unk1_unk2)))); + __pyx_t_62 = __pyx_v_col1; + __pyx_t_63 = __pyx_v_col2; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_62 * __pyx_v_distances.strides[0]) ) + __pyx_t_63 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; + __pyx_t_64 = __pyx_v_col2; + __pyx_t_65 = __pyx_v_col1; + *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_64 * __pyx_v_distances.strides[0]) ) + __pyx_t_65 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; - /* "Orange/distance/_distance.pyx":553 - * elif val1 != 0 or val2 != 0: - * in_one += 1 - * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< - * 1 - float(in_both - * + ps[col1] * unk1_in2 + + /* "Orange/distance/_distance.pyx":507 + * in_both += ival1 & ival2 + * in_any += ival1 | ival2 + * if in_any != 0: # <<<<<<<<<<<<<< + * distances[col1, col2] = distances[col2, col1] = \ + * 1 - float(in_both) / in_any */ - __pyx_t_32 = __pyx_v_col1; - __pyx_t_33 = __pyx_v_col2; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; - __pyx_t_34 = __pyx_v_col2; - __pyx_t_35 = __pyx_v_col1; - *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_34 * __pyx_v_distances.strides[0]) ) + __pyx_t_35 * __pyx_v_distances.strides[1]) )) = __pyx_t_31; + } + } + __pyx_L19:; + } } + __pyx_L8:; } } - /* "Orange/distance/_distance.pyx":529 + /* "Orange/distance/_distance.pyx":438 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< * for col1 in range(n_cols): - * for col2 in range(col1): + * if nans[col1]: */ /*finally:*/ { /*normal exit:*/{ @@ -10156,47 +9419,51 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":562 - * + ps[col2] * not1_unk2 - * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + /* "Orange/distance/_distance.pyx":511 + * 1 - float(in_both) / in_any + * * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":518 + /* "Orange/distance/_distance.pyx":425 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x, + * np.ndarray[np.int8_t, ndim=1] nans, */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ps.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nans.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nonzeros.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ps.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; - __PYX_XDEC_MEMVIEW(&__pyx_v_ps, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); @@ -10372,7 +9639,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10428,7 +9695,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * info.buf = PyArray_DATA(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10737,7 +10004,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11552,7 +10819,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11620,7 +10887,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11729,7 +10996,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -12510,7 +11777,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if itemsize <= 0: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12542,7 +11809,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if not isinstance(format, bytes): */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12577,7 +11844,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); @@ -12653,7 +11920,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -12937,7 +12204,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if self.dtype_is_object: */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -13175,7 +12442,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(stru * info.buf = self.data * info.len = self.len */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -16122,7 +15389,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview * else: * if len(self.view.format) == 1: */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -16942,7 +16209,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -17056,7 +16323,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__17, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__15, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; @@ -18360,9 +17627,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_7); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__18); - __Pyx_GIVEREF(__pyx_slice__18); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__18); + __Pyx_INCREF(__pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__16); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) @@ -18395,7 +17662,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * else: */ /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__19); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__17); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) } __pyx_L7:; @@ -18540,9 +17807,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__20); - __Pyx_GIVEREF(__pyx_slice__20); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__20); + __Pyx_INCREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__18); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) @@ -18666,7 +17933,7 @@ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -24609,10 +23876,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_n_s_abs1, __pyx_k_abs1, sizeof(__pyx_k_abs1), 0, 0, 1, 1}, - {&__pyx_n_s_abs2, __pyx_k_abs2, sizeof(__pyx_k_abs2), 0, 0, 1, 1}, - {&__pyx_n_s_abss, __pyx_k_abss, sizeof(__pyx_k_abss), 0, 0, 1, 1}, {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_any_nan_row, __pyx_k_any_nan_row, sizeof(__pyx_k_any_nan_row), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, @@ -24622,24 +23887,23 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_cosine_cols, __pyx_k_cosine_cols, sizeof(__pyx_k_cosine_cols), 0, 0, 1, 1}, - {&__pyx_n_s_cosine_rows, __pyx_k_cosine_rows, sizeof(__pyx_k_cosine_rows), 0, 0, 1, 1}, {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, + {&__pyx_n_s_dist_missing2_cont, __pyx_k_dist_missing2_cont, sizeof(__pyx_k_dist_missing2_cont), 0, 0, 1, 1}, {&__pyx_n_s_distances, __pyx_k_distances, sizeof(__pyx_k_distances), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, - {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_euclidean_rows_discrete, __pyx_k_euclidean_rows_discrete, sizeof(__pyx_k_euclidean_rows_discrete), 0, 0, 1, 1}, - {&__pyx_n_s_fit_params, __pyx_k_fit_params, sizeof(__pyx_k_fit_params), 0, 0, 1, 1}, {&__pyx_n_s_fix_euclidean_cols, __pyx_k_fix_euclidean_cols, sizeof(__pyx_k_fix_euclidean_cols), 0, 0, 1, 1}, {&__pyx_n_s_fix_euclidean_cols_normalized, __pyx_k_fix_euclidean_cols_normalized, sizeof(__pyx_k_fix_euclidean_cols_normalized), 0, 0, 1, 1}, {&__pyx_n_s_fix_euclidean_rows, __pyx_k_fix_euclidean_rows, sizeof(__pyx_k_fix_euclidean_rows), 0, 0, 1, 1}, {&__pyx_n_s_fix_euclidean_rows_normalized, __pyx_k_fix_euclidean_rows_normalized, sizeof(__pyx_k_fix_euclidean_rows_normalized), 0, 0, 1, 1}, + {&__pyx_n_s_fix_manhattan_rows, __pyx_k_fix_manhattan_rows, sizeof(__pyx_k_fix_manhattan_rows), 0, 0, 1, 1}, + {&__pyx_n_s_fix_manhattan_rows_normalized, __pyx_k_fix_manhattan_rows_normalized, sizeof(__pyx_k_fix_manhattan_rows_normalized), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, @@ -24648,8 +23912,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_in1_unk2, __pyx_k_in1_unk2, sizeof(__pyx_k_in1_unk2), 0, 0, 1, 1}, + {&__pyx_n_s_in_any, __pyx_k_in_any, sizeof(__pyx_k_in_any), 0, 0, 1, 1}, {&__pyx_n_s_in_both, __pyx_k_in_both, sizeof(__pyx_k_in_both), 0, 0, 1, 1}, - {&__pyx_n_s_in_one, __pyx_k_in_one, sizeof(__pyx_k_in_one), 0, 0, 1, 1}, + {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1}, {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, @@ -24660,7 +23925,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_mads, __pyx_k_mads, sizeof(__pyx_k_mads), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_manhattan_cols, __pyx_k_manhattan_cols, sizeof(__pyx_k_manhattan_cols), 0, 0, 1, 1}, - {&__pyx_n_s_manhattan_rows, __pyx_k_manhattan_rows, sizeof(__pyx_k_manhattan_rows), 0, 0, 1, 1}, + {&__pyx_n_s_manhattan_rows_cont, __pyx_k_manhattan_rows_cont, sizeof(__pyx_k_manhattan_rows_cont), 0, 0, 1, 1}, {&__pyx_n_s_means, __pyx_k_means, sizeof(__pyx_k_means), 0, 0, 1, 1}, {&__pyx_n_s_medians, __pyx_k_medians, sizeof(__pyx_k_medians), 0, 0, 1, 1}, {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, @@ -24671,11 +23936,16 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_n_rows2, __pyx_k_n_rows2, sizeof(__pyx_k_n_rows2), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, + {&__pyx_n_s_nans, __pyx_k_nans, sizeof(__pyx_k_nans), 0, 0, 1, 1}, + {&__pyx_n_s_nans1, __pyx_k_nans1, sizeof(__pyx_k_nans1), 0, 0, 1, 1}, + {&__pyx_n_s_nans2, __pyx_k_nans2, sizeof(__pyx_k_nans2), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, {&__pyx_n_s_nonnans, __pyx_k_nonnans, sizeof(__pyx_k_nonnans), 0, 0, 1, 1}, {&__pyx_n_s_nonzeros, __pyx_k_nonzeros, sizeof(__pyx_k_nonzeros), 0, 0, 1, 1}, + {&__pyx_n_s_nonzeros1, __pyx_k_nonzeros1, sizeof(__pyx_k_nonzeros1), 0, 0, 1, 1}, + {&__pyx_n_s_nonzeros2, __pyx_k_nonzeros2, sizeof(__pyx_k_nonzeros2), 0, 0, 1, 1}, {&__pyx_n_s_normalize, __pyx_k_normalize, sizeof(__pyx_k_normalize), 0, 0, 1, 1}, {&__pyx_n_s_not1_unk2, __pyx_k_not1_unk2, sizeof(__pyx_k_not1_unk2), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, @@ -24738,20 +24008,6 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "Orange/distance/_distance.pyx":440 - * for col1 in range(n_cols): - * if vars[col1] == -2: - * distances[col1, :] = distances[:, col1] = 1.0 # <<<<<<<<<<<<<< - * continue - * with nogil: - */ - __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice_); - __Pyx_GIVEREF(__pyx_slice_); - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 440, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): @@ -24759,9 +24015,9 @@ static int __Pyx_InitCachedConstants(void) { * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) @@ -24770,9 +24026,9 @@ static int __Pyx_InitCachedConstants(void) { * * info.buf = PyArray_DATA(self) */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or @@ -24781,9 +24037,9 @@ static int __Pyx_InitCachedConstants(void) { * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * @@ -24792,9 +24048,9 @@ static int __Pyx_InitCachedConstants(void) { * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 799, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or @@ -24803,9 +24059,9 @@ static int __Pyx_InitCachedConstants(void) { * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num @@ -24814,9 +24070,9 @@ static int __Pyx_InitCachedConstants(void) { * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "View.MemoryView":131 * @@ -24825,9 +24081,9 @@ static int __Pyx_InitCachedConstants(void) { * * if itemsize <= 0: */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); /* "View.MemoryView":134 * @@ -24836,9 +24092,9 @@ static int __Pyx_InitCachedConstants(void) { * * if not isinstance(format, bytes): */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); /* "View.MemoryView":137 * @@ -24847,9 +24103,9 @@ static int __Pyx_InitCachedConstants(void) { * self._format = format # keep a reference to the byte string * self.format = self._format */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); /* "View.MemoryView":146 * @@ -24858,9 +24114,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); /* "View.MemoryView":174 * self.data = malloc(self.len) @@ -24869,9 +24125,9 @@ static int __Pyx_InitCachedConstants(void) { * * if self.dtype_is_object: */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); /* "View.MemoryView":190 * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS @@ -24880,9 +24136,9 @@ static int __Pyx_InitCachedConstants(void) { * info.buf = self.data * info.len = self.len */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); /* "View.MemoryView":484 * result = struct.unpack(self.view.format, bytesitem) @@ -24891,9 +24147,9 @@ static int __Pyx_InitCachedConstants(void) { * else: * if len(self.view.format) == 1: */ - __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 484, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 484, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); /* "View.MemoryView":556 * if self.view.strides == NULL: @@ -24902,9 +24158,9 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 556, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); /* "View.MemoryView":563 * def suboffsets(self): @@ -24913,12 +24169,12 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) */ - __pyx_tuple__17 = PyTuple_New(1); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); + __pyx_tuple__15 = PyTuple_New(1); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__17, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__17); + PyTuple_SET_ITEM(__pyx_tuple__15, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__15); /* "View.MemoryView":668 * if item is Ellipsis: @@ -24927,9 +24183,9 @@ static int __Pyx_InitCachedConstants(void) { * seen_ellipsis = True * else: */ - __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__18); - __Pyx_GIVEREF(__pyx_slice__18); + __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); /* "View.MemoryView":671 * seen_ellipsis = True @@ -24938,9 +24194,9 @@ static int __Pyx_InitCachedConstants(void) { * have_slices = True * else: */ - __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(2, 671, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__19); - __Pyx_GIVEREF(__pyx_slice__19); + __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(2, 671, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__17); + __Pyx_GIVEREF(__pyx_slice__17); /* "View.MemoryView":682 * nslices = ndim - len(result) @@ -24949,9 +24205,9 @@ static int __Pyx_InitCachedConstants(void) { * * return have_slices or nslices, tuple(result) */ - __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__20); - __Pyx_GIVEREF(__pyx_slice__20); + __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); /* "View.MemoryView":689 * for suboffset in suboffsets[:ndim]: @@ -24960,9 +24216,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); + __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); /* "Orange/distance/_distance.pyx":25 * @@ -24971,10 +24227,10 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__22 = PyTuple_Pack(17, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(6, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows_discrete, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_tuple__20 = PyTuple_Pack(17, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 25, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(6, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows_discrete, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 25, __pyx_L1_error) /* "Orange/distance/_distance.pyx":59 * @@ -24983,10 +24239,10 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__24 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 59, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__24); - __Pyx_GIVEREF(__pyx_tuple__24); - __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_tuple__22 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 59, __pyx_L1_error) /* "Orange/distance/_distance.pyx":94 * @@ -24995,10 +24251,10 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__26 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__26); - __Pyx_GIVEREF(__pyx_tuple__26); - __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows_normalized, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_tuple__24 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows_normalized, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 94, __pyx_L1_error) /* "Orange/distance/_distance.pyx":129 * @@ -25007,10 +24263,10 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_tuple__28 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__28); - __Pyx_GIVEREF(__pyx_tuple__28); - __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_tuple__26 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 129, __pyx_L1_error) /* "Orange/distance/_distance.pyx":159 * @@ -25019,94 +24275,106 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_tuple__30 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); - __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols_normalized, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_tuple__28 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols_normalized, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 159, __pyx_L1_error) /* "Orange/distance/_distance.pyx":188 * * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables): + */ + __pyx_tuple__30 = PyTuple_Pack(13, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows_cont, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 188, __pyx_L1_error) + + /* "Orange/distance/_distance.pyx":211 + * return distances + * + * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__32 = PyTuple_Pack(21, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_normalize, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_tuple__32 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing2_cont, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_manhattan_rows, 211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 211, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":251 + /* "Orange/distance/_distance.pyx":246 * * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__34 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_tuple__34 = PyTuple_Pack(13, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); - __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 251, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_manhattan_rows_normalized, 246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 246, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":296 + /* "Orange/distance/_distance.pyx":278 * * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=1] medians, + * np.ndarray[np.float64_t, ndim=1] mads, */ - __pyx_tuple__36 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_tuple__36 = PyTuple_Pack(13, __pyx_n_s_x, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); - __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 296, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 278, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 278, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":319 * * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans */ - __pyx_tuple__38 = PyTuple_Pack(19, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_dist_missing2, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abs1, __pyx_n_s_abs2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 340, __pyx_L1_error) + __pyx_tuple__38 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38); - __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(4, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_rows, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 340, __pyx_L1_error) + __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 319, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 319, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":422 - * + /* "Orange/distance/_distance.pyx":333 + * return float(nonzeros) / nonnans * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< * cdef: - * double [:] vars = fit_params["vars"] + * int row, n_cols, n_rows */ - __pyx_tuple__40 = PyTuple_Pack(14, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_vars, __pyx_n_s_means, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_row, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_abss, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_tuple__40 = PyTuple_Pack(6, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_n_cols, __pyx_n_s_n_rows, __pyx_n_s_flags, __pyx_n_s_col); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 333, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__40); __Pyx_GIVEREF(__pyx_tuple__40); - __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_cosine_cols, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_any_nan_row, 333, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 333, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":349 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< + * np.ndarray[np.int8_t, ndim=2] nonzeros2, + * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__42 = PyTuple_Pack(18, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_tuple__42 = PyTuple_Pack(21, __pyx_n_s_nonzeros1, __pyx_n_s_nonzeros2, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_nans1, __pyx_n_s_nans2, __pyx_n_s_ps, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 349, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); - __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 467, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(8, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 349, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 349, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":518 + /* "Orange/distance/_distance.pyx":425 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x, + * np.ndarray[np.int8_t, ndim=1] nans, */ - __pyx_tuple__44 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_fit_params, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_in_both, __pyx_n_s_in_one, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 518, __pyx_L1_error) + __pyx_tuple__44 = PyTuple_Pack(23, __pyx_n_s_nonzeros, __pyx_n_s_x, __pyx_n_s_nans, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_in_both, __pyx_n_s_in_any, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); - __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 518, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 518, __pyx_L1_error) + __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(4, 0, 23, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 425, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 425, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -25171,7 +24439,6 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -25395,85 +24662,97 @@ PyMODINIT_FUNC PyInit__distance(void) /* "Orange/distance/_distance.pyx":188 * * - * def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x2, + * char two_tables): */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows_cont, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 188, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows_cont, __pyx_t_1) < 0) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":251 - * + /* "Orange/distance/_distance.pyx":211 + * return distances * - * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] medians = fit_params["medians"] + * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13fix_manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 251, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":296 + /* "Orange/distance/_distance.pyx":246 * * - * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< - * cdef: - * int row, nonzeros, nonnans + * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 296, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":278 * * - * def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=1] medians, + * np.ndarray[np.float64_t, ndim=1] mads, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17cosine_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_rows, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":422 + /* "Orange/distance/_distance.pyx":319 + * * + * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< + * cdef: + * int row, nonzeros, nonnans + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_19p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "Orange/distance/_distance.pyx":333 + * return float(nonzeros) / nonnans * - * def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< + * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< * cdef: - * double [:] vars = fit_params["vars"] + * int row, n_cols, n_rows */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_19cosine_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_21any_nan_row, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cosine_cols, __pyx_t_1) < 0) __PYX_ERR(0, 422, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_any_nan_row, __pyx_t_1) < 0) __PYX_ERR(0, 333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":349 * * - * def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x2, - * char two_tables, + * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< + * np.ndarray[np.int8_t, ndim=2] nonzeros2, + * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_21jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_23jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 467, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 349, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":518 + /* "Orange/distance/_distance.pyx":425 * * - * def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): # <<<<<<<<<<<<<< - * cdef: - * double [:] ps = fit_params["ps"] + * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x, + * np.ndarray[np.int8_t, ndim=1] nans, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_23jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_25jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 518, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 @@ -26599,63 +25878,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg } #endif -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - /* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; @@ -26668,13 +25892,13 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } /* BufferFallbackError */ - static void __Pyx_RaiseBufferFallbackError(void) { + static void __Pyx_RaiseBufferFallbackError(void) { PyErr_SetString(PyExc_ValueError, "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); } /* RaiseException */ - #if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare @@ -26837,25 +26061,25 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* BytesEquals */ - static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26893,7 +26117,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* UnicodeEquals */ - static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26977,7 +26201,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* GetAttr */ - static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { + static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) @@ -26990,7 +26214,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* decode_c_string */ - static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { @@ -27023,7 +26247,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* SaveResetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -27047,7 +26271,7 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { PyObject *exc_type = tstate->curexc_type; if (exc_type == err) return 1; @@ -27057,7 +26281,7 @@ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tsta #endif /* GetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -27118,7 +26342,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SwapException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -27143,7 +26367,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, #endif /* Import */ - 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; @@ -27217,7 +26441,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, } /* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); @@ -27298,7 +26522,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, } /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -27396,12 +26620,12 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED #endif /* None */ - static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } /* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; @@ -27442,6 +26666,61 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED #endif } +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + /* SetVTable */ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 @@ -28046,6 +27325,33 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o return 1; } +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) { + const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(Py_intptr_t) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(Py_intptr_t) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t), + little, !is_unsigned); + } +} + /* None */ #if CYTHON_CCOMPLEX #ifdef __cplusplus diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index 1484aef9772..2c75c01c421 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -185,75 +185,101 @@ def fix_euclidean_cols_normalized( distances[col1, col2] = distances[col2, col1] = d -def manhattan_rows(np.ndarray[np.float64_t, ndim=2] x1, - np.ndarray[np.float64_t, ndim=2] x2, - char two_tables, - fit_params): +def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + char two_tables): cdef: - double [:] medians = fit_params["medians"] - double [:] mads = fit_params["mads"] - double [:, :] dist_missing = fit_params["dist_missing"] - double [:] dist_missing2 = fit_params["dist_missing2"] - char normalize = fit_params["normalize"] - int n_rows1, n_rows2, n_cols, row1, row2, col double val1, val2, d - int ival1, ival2 - double [:, :] distances + np.ndarray[np.float64_t, ndim=2] distances n_rows1, n_cols = x1.shape[0], x1.shape[1] n_rows2 = x2.shape[0] - assert n_cols == x2.shape[1] == len(mads) == len(medians) \ - == len(dist_missing) == len(dist_missing2) - distances = np.zeros((n_rows1, n_rows2), dtype=float) with nogil: for row1 in range(n_rows1): for row2 in range(n_rows2 if two_tables else row1): d = 0 for col in range(n_cols): - if mads[col] == -2: - continue + d += fabs(x1[row1, col] - x2[row2, col]) + distances[row1, row2] = d + # TODO: Do this only at the end, not after each function + if not two_tables: + _lower_to_symmetric(distances) + return distances - val1, val2 = x1[row1, col], x2[row2, col] - if npy_isnan(val1) and npy_isnan(val2): - d += dist_missing2[col] - elif mads[col] == -1: - ival1, ival2 = int(val1), int(val2) - if npy_isnan(val1): - d += dist_missing[col, ival2] - elif npy_isnan(val2): - d += dist_missing[col, ival1] - elif ival1 != ival2: - d += 1 - elif normalize: - if npy_isnan(val1): - d += fabs(val2 - medians[col]) / mads[col] / 2 + 0.5 - elif npy_isnan(val2): - d += fabs(val1 - medians[col]) / mads[col] / 2 + 0.5 - else: - d += fabs(val1 - val2) / mads[col] / 2 - else: +def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + np.ndarray[np.float64_t, ndim=1] medians, + np.ndarray[np.float64_t, ndim=1] mads, + np.ndarray[np.float64_t, ndim=1] dist_missing2_cont, + char two_tables): + cdef: + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] if two_tables else 0 + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + if npy_isnan(distances[row1, row2]): + d = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x2[row2, col] if npy_isnan(val1): - d += fabs(val2 - medians[col]) + mads[col] + if npy_isnan(val2): + d += dist_missing2_cont[col] + else: + d += fabs(val2 - medians[col]) + mads[col] elif npy_isnan(val2): d += fabs(val1 - medians[col]) + mads[col] else: d += fabs(val1 - val2) + distances[row1, row2] = d + if not two_tables: + _lower_to_symmetric(distances) + return distances - distances[row1, row2] = d +def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, + np.ndarray[np.float64_t, ndim=2] x1, + np.ndarray[np.float64_t, ndim=2] x2, + char two_tables): + cdef: + int n_rows1, n_rows2, n_cols, row1, row2, col + double val1, val2, d + + n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows2 = x2.shape[0] if two_tables else 0 + with nogil: + for row1 in range(n_rows1): + for row2 in range(n_rows2 if two_tables else row1): + if npy_isnan(distances[row1, row2]): + d = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1): + if npy_isnan(val2): + d += 1 + else: + d += fabs(val2) + 0.5 + elif npy_isnan(val2): + d += fabs(val1) + 0.5 + else: + d += fabs(val1 - val2) + distances[row1, row2] = d if not two_tables: _lower_to_symmetric(distances) return distances -def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): +def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, + np.ndarray[np.float64_t, ndim=1] medians, + np.ndarray[np.float64_t, ndim=1] mads, + char normalize): cdef: - double [:] medians = fit_params["medians"] - double [:] mads = fit_params["mads"] - char normalize = fit_params["normalize"] - int n_rows, n_cols, col1, col2, row double val1, val2, d double [:, :] distances @@ -266,27 +292,24 @@ def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): d = 0 for row in range(n_rows): val1, val2 = x[row, col1], x[row, col2] - if normalize: - val1 = (val1 - medians[col1]) / (2 * mads[col1]) - val2 = (val2 - medians[col2]) / (2 * mads[col2]) - if npy_isnan(val1): - if npy_isnan(val2): + if npy_isnan(val1): + if npy_isnan(val2): + if normalize: d += 1 else: - d += fabs(val2) + 0.5 - elif npy_isnan(val2): - d += fabs(val1) + 0.5 - else: - d += fabs(val1 - val2) - else: - if npy_isnan(val1): - if npy_isnan(val2): d += mads[col1] + mads[col2] \ - + fabs(medians[col1] - medians[col2]) + + fabs(medians[col1] - medians[col2]) + else: + if normalize: + d += fabs(val2) + 0.5 else: d += fabs(val2 - medians[col1]) + mads[col1] - elif npy_isnan(val2): - d += fabs(val1 - medians[col2]) + mads[col2] + else: + if npy_isnan(val2): + if normalize: + d += fabs(val1) + 0.5 + else: + d += fabs(val1 - medians[col2]) + mads[col2] else: d += fabs(val1 - val2) distances[col1, col2] = distances[col2, col1] = d @@ -307,256 +330,182 @@ def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): nonzeros += 1 return float(nonzeros) / nonnans - -cdef _abs_rows(double [:, :] x, double[:] means, double[:] vars): +def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): cdef: - double [:] abss - double d, val - int row, col, n_rows, n_cols + int row, n_cols, n_rows + np.ndarray[np.int8_t, ndim=1] flags n_rows, n_cols = x.shape[0], x.shape[1] - abss = np.empty(n_rows) + flags = np.zeros(x.shape[0], dtype=np.int8) with nogil: for row in range(n_rows): - d = 0 for col in range(n_cols): - if vars[col] == -2: - continue - val = x[row, col] - if vars[col] == -1: - if npy_isnan(val): - d += means[col] - elif val != 0: - d += 1 - else: - if npy_isnan(val): - d += means[col] ** 2 + vars[col] - else: - d += val ** 2 - abss[row] = sqrt(d) - return abss - - -def cosine_rows(np.ndarray[np.float64_t, ndim=2] x1, - np.ndarray[np.float64_t, ndim=2] x2, - char two_tables, - fit_params): - cdef: - double [:] vars = fit_params["vars"] - double [:] means = fit_params["means"] - double [:] dist_missing2 = fit_params["dist_missing2"] - - int n_rows1, n_rows2, n_cols, row1, row2, col - double val1, val2, d - double [:] abs1, abs2 - double [:, :] distances - - n_rows1, n_cols = x1.shape[0], x1.shape[1] - n_rows2 = x2.shape[0] - assert n_cols == x2.shape[1] == len(vars) == len(means) \ - == len(dist_missing2) - abs1 = _abs_rows(x1, means, vars) - abs2 = _abs_rows(x2, means, vars) if two_tables else abs1 - distances = np.zeros((n_rows1, n_rows2), dtype=float) - - with nogil: - for row1 in range(n_rows1): - for row2 in range(n_rows2 if two_tables else row1): - d = 0 - for col in range(n_cols): - if vars[col] == -2: - continue - val1, val2 = x1[row1, col], x2[row2, col] - if npy_isnan(val1) and npy_isnan(val2): - d += dist_missing2[col] - elif vars[col] == -1: - if npy_isnan(val1) and val2 != 0 \ - or npy_isnan(val2) and val1 != 0: - d += means[col] - elif val1 != 0 and val2 != 0: - d += 1 - else: - if npy_isnan(val1): - d += val2 * means[col] - elif npy_isnan(val2): - d += val1 * means[col] - else: - d += val1 * val2 - d = 1 - d / abs1[row1] / abs2[row2] - if d < 0: # clip off any numeric errors - d = 0 - elif d > 1: - d = 1 - distances[row1, row2] = d - if not two_tables: - _lower_to_symmetric(distances) - return distances - - -cdef _abs_cols(double [:, :] x, double[:] means, double[:] vars): - cdef: - double [:] abss - double d, val - int row, col, n_rows, n_cols, nan_cont - - n_rows, n_cols = x.shape[0], x.shape[1] - abss = np.empty(n_cols) - with nogil: - for col in range(n_cols): - if vars[col] == -2: - abss[col] = 1 - continue - d = 0 - nan_cont = 0 - for row in range(n_rows): - val = x[row, col] - if npy_isnan(val): - nan_cont += 1 - else: - d += val ** 2 - d += nan_cont * (means[col] ** 2 + vars[col]) - abss[col] = sqrt(d) - return abss - - -def cosine_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): - cdef: - double [:] vars = fit_params["vars"] - double [:] means = fit_params["means"] - - int n_rows, n_cols, row, col1, col2 - double val1, val2, d - double [:] abss - # This can't be a memoryview (double[:, :]) because of - # distances[col1, :] = distances[:, col1] = 1.0 - np.ndarray[np.float64_t, ndim=2] distances - - n_rows, n_cols = x.shape[0], x.shape[1] - assert n_cols == len(vars) == len(means) - abss = _abs_cols(x, means, vars) - distances = np.zeros((n_cols, n_cols), dtype=float) - for col1 in range(n_cols): - if vars[col1] == -2: - distances[col1, :] = distances[:, col1] = 1.0 - continue - with nogil: - for col2 in range(col1): - if vars[col2] == -2: - continue - d = 0 - for row in range(n_rows): - val1, val2 = x[row, col1], x[row, col2] - if npy_isnan(val1) and npy_isnan(val2): - d += means[col1] * means[col2] - elif npy_isnan(val1): - d += val2 * means[col1] - elif npy_isnan(val2): - d += val1 * means[col2] - else: - d += val1 * val2 + if npy_isnan(x[row, col]): + flags[row] = 1 + break + return flags - d = 1 - d / abss[col1] / abss[col2] - if d < 0: # clip off any numeric errors - d = 0 - elif d > 1: - d = 1 - distances[col1, col2] = distances[col2, col1] = d - return distances - -def jaccard_rows(np.ndarray[np.float64_t, ndim=2] x1, +def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, + np.ndarray[np.int8_t, ndim=2] nonzeros2, + np.ndarray[np.float64_t, ndim=2] x1, np.ndarray[np.float64_t, ndim=2] x2, - char two_tables, - fit_params): + np.ndarray[np.int8_t, ndim=1] nans1, + np.ndarray[np.int8_t, ndim=1] nans2, + np.ndarray[np.float64_t, ndim=1] ps, + char two_tables): cdef: - double [:] ps = fit_params["ps"] - int n_rows1, n_rows2, n_cols, row1, row2, col - double val1, val2, intersection, union + np.float64_t val1, val2, intersection, union int ival1, ival2 double [:, :] distances - n_rows1, n_cols = x1.shape[0], x1.shape[1] + n_rows1, n_cols = x1.shape[0], x2.shape[1] n_rows2 = x2.shape[0] - assert n_cols == x2.shape[1] == ps.shape[0] - distances = np.zeros((n_rows1, n_rows2), dtype=float) with nogil: for row1 in range(n_rows1): - for row2 in range(n_rows2 if two_tables else row1): - intersection = union = 0 - for col in range(n_cols): - val1, val2 = x1[row1, col], x2[row2, col] - if npy_isnan(val1): - if npy_isnan(val2): - intersection += ps[col] ** 2 - union += 1 - (1 - ps[col]) ** 2 - elif val2 != 0: - intersection += ps[col] - union += 1 - else: - union += ps[col] - elif npy_isnan(val2): - if val1 != 0: - intersection += ps[col] - union += 1 + if nans1[row1]: + for row2 in range(n_rows2 if two_tables else row1): + union = intersection = 0 + for col in range(n_cols): + val1, val2 = x1[row1, col], x2[row2, col] + if npy_isnan(val1): + if npy_isnan(val2): + intersection += ps[col] ** 2 + union += 1 - (1 - ps[col]) ** 2 + elif val2 != 0: + intersection += ps[col] + union += 1 + else: + union += ps[col] + elif npy_isnan(val2): + if val1 != 0: + intersection += val1 * ps[col] + union += 1 + else: + union += ps[col] else: - union += ps[col] + ival1 = nonzeros1[row1, col] + ival2 = nonzeros2[row2, col] + union += ival1 | ival2 + intersection += ival1 & ival2 + if union != 0: + distances[row1, row2] = 1 - intersection / union + else: + for row2 in range(n_rows2 if two_tables else row1): + union = intersection = 0 + # This case is slightly different since val1 can't be nan + if nans2[row2]: + for col in range(n_cols): + val2 = x2[row2, col] + if nonzeros1[row1, col] != 0: + union += 1 + if npy_isnan(val2): + intersection += ps[col] + elif val2 != 0: + intersection += 1 + elif npy_isnan(val2): + union += ps[col] + elif val2 != 0: + union += 1 else: - if val1 != 0 and val2 != 0: - intersection += 1 - if val1 != 0 or val2 != 0: - union += 1 - if union != 0: - distances[row1, row2] = 1 - intersection / union - + for col in range(n_cols): + ival1 = nonzeros1[row1, col] + ival2 = nonzeros2[row2, col] + union += ival1 | ival2 + intersection += ival1 & ival2 + if union != 0: + distances[row1, row2] = 1 - intersection / union if not two_tables: _lower_to_symmetric(distances) return distances -def jaccard_cols(np.ndarray[np.float64_t, ndim=2] x, fit_params): +def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, + np.ndarray[np.float64_t, ndim=2] x, + np.ndarray[np.int8_t, ndim=1] nans, + np.ndarray[np.float64_t, ndim=1] ps): cdef: - double [:] ps = fit_params["ps"] - int n_rows, n_cols, col1, col2, row - double val1, val2 - int in_both, in_one, in1_unk2, unk1_in2, unk1_unk2, unk1_not2, not1_unk2 + double val1, val2, intersection, union + np.int8_t ival1, ival2 + int in_both, in_any, in1_unk2, unk1_in2, unk1_unk2, unk1_not2, not1_unk2 double [:, :] distances n_rows, n_cols = x.shape[0], x.shape[1] distances = np.zeros((n_cols, n_cols), dtype=float) with nogil: for col1 in range(n_cols): - for col2 in range(col1): - in_both = in_one = 0 - in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 - for row in range(n_rows): - val1, val2 = x[row, col1], x[row, col2] - if npy_isnan(val1): - if npy_isnan(val2): - unk1_unk2 += 1 - elif val2 != 0: - unk1_in2 += 1 - else: - unk1_not2 += 1 - elif npy_isnan(val2): - if val1 != 0: - in1_unk2 += 1 + if nans[col1]: + for col2 in range(col1): + in_both = in_any = 0 + in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + for row in range(n_rows): + val1, val2 = x[row, col1], x[row, col2] + if npy_isnan(val1): + if npy_isnan(val2): + unk1_unk2 += 1 + elif val2 != 0: + unk1_in2 += 1 + else: + unk1_not2 += 1 + elif npy_isnan(val2): + if val1 != 0: + in1_unk2 += 1 + else: + not1_unk2 += 1 else: - not1_unk2 += 1 + ival1 = nonzeros[row, col1] + ival2 = nonzeros[row, col2] + in_both += ival1 & ival2 + in_any += ival1 | ival2 + union = (in_any + unk1_in2 + in1_unk2 + + ps[col1] * unk1_not2 + + ps[col2] * not1_unk2 + + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + if union != 0: + intersection = (in_both + + ps[col1] * unk1_in2 + + + ps[col2] * in1_unk2 + + + ps[col1] * ps[col2] * unk1_unk2) + distances[col1, col2] = distances[col2, col1] = \ + 1 - intersection / union + else: + for col2 in range(col1): + if nans[col2]: + in_both = in_any = 0 + in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 + for row in range(n_rows): + ival1 = nonzeros[row, col1] + val2 = x[row, col2] + if npy_isnan(val2): + if ival1: + in1_unk2 += 1 + else: + not1_unk2 += 1 + else: + ival2 = nonzeros[row, col2] + in_both += ival1 & ival2 + in_any += ival1 | ival2 + distances[col1, col2] = distances[col2, col1] = \ + 1 - float(in_both + + ps[col1] * unk1_in2 + + + ps[col2] * in1_unk2 + + + ps[col1] * ps[col2] * unk1_unk2) / \ + (in_any + unk1_in2 + in1_unk2 + + + ps[col1] * unk1_not2 + + ps[col2] * not1_unk2 + + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) else: - if val1 != 0 and val2 != 0: - in_both += 1 - elif val1 != 0 or val2 != 0: - in_one += 1 - distances[col1, col2] = distances[col2, col1] = \ - 1 - float(in_both - + ps[col1] * unk1_in2 + - + ps[col2] * in1_unk2 + - + ps[col1] * ps[col2] * unk1_unk2) / \ - (in_both + in_one + unk1_in2 + in1_unk2 + - + ps[col1] * unk1_not2 - + ps[col2] * not1_unk2 - + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) + in_both = in_any = 0 + for row in range(n_rows): + ival1 = nonzeros[row, col1] + ival2 = nonzeros[row, col2] + in_both += ival1 & ival2 + in_any += ival1 | ival2 + if in_any != 0: + distances[col1, col2] = distances[col2, col1] = \ + 1 - float(in_both) / in_any + return distances diff --git a/Orange/distance/distances.md b/Orange/distance/distances.md index 9aaa4123ba2..86f76c9ce20 100644 --- a/Orange/distance/distances.md +++ b/Orange/distance/distances.md @@ -28,7 +28,7 @@ Normalized values thus have a mean of $\mu'=0$ and a variance of $\sigma'^2 = 1/ If one value (denoted by $v$) is known and one missing, the expected difference along this dimension is -$$\int_{-\infty}^{\infty}(v - x)^2p(x)dx = \\ +$$\int_{-\infty}^{\infty}(v - x)^2p(x)dx = \\ v^2\int_{-\infty}^{\infty}p(x)dx- 2v\int_{-\infty}^{\infty}xp(x) + \int_{-\infty}^{\infty}x^2p(x) = \\ v^2 - 2v\mu + (\sigma^2 + \mu^2) = \\ (v - \mu)^2 + \sigma^2.$$ @@ -41,7 +41,7 @@ $$\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}(x - y)^2p(x)p(y)dxdy = \\ - 2\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}xyp(x)p(y)dxdy = \\ (\sigma^2 + \mu^2) + (\sigma^2 + \mu^2) - 2\int_{-\infty}^{\infty}xp(x)dx\int_{-\infty}^{\infty}yp(y)dxdy = \\ (\sigma^2 + \mu^2) + (\sigma^2 + \mu^2) - 2\mu\mu = \\ - 2\sigma^2.$$ + 2\sigma^2.$$ When computing the difference between columns, the derivation is similar except that the two distributions are not the same. For one missing value we get @@ -109,10 +109,12 @@ $$\int_{-\infty}^{\infty}xp(x)yp(y)dxdy=\mu_x^2$$ For discrete values, we compute the probabilities $p(x=0)$ and $p_x(x\ne 0)$. The product of known value $v$ and a missing value is 0 if v=0 and $p(x \ne 1)$ otherwise. The product of two missing values is $p(x\ne 1)^2$. -When computing the absolute value of a row, a missing value of continuous variable contributes +When computing the absolute value of a row, a missing value of continuous variable theoretically contributes $$\int_{-infty}^{\infty}x^2p(x)dx = \mu_x^2 + \sigma_x^2$$ +However, since we essentially impute the mean in the dot product, the actual contribution of the missing value is $\mu_x^2$. We therefore use this value, which also simplifies the computation which is reduced to simple imputation of means. + A missing value of discrete variable contributes $$1\cdot 1\;p(x\ne 0) = p(x\ne 0)$$ diff --git a/Orange/distance/tests/calculation.xlsx b/Orange/distance/tests/calculation.xlsx index 8f8aa3f7df2ab210544c08d7bcabdf1bc386ed6e..c75b6f215d67eef1ffccc683bd8b6271cc13f55c 100644 GIT binary patch delta 29261 zcmb@t2UJtvw=No_OYcYvO+;Gg9YT>VA|fC)2m;bkT7W?4y(ke-kfKznDotsjgS05U zLugVZ0f7JkZhrrB&N%nJbKe>7j{C;gJ7Z^N?X}ka=A7S}bFS>76q2)8lF!YQqTy5y(U%T=FRNcNFOdv5CGA92I;E+@=g!U6t@Ivi##o5yr4N6k z8wx^-J(yG7YY4}5M1EBg$*bICx3QKs*h{T>8md{X>9ATIrlzcRkA$5l|EsD20 z!#6gB&hLm7c<#IM#!I&PwpmS(<6B(RsshgT21{Kbl48+~wM)id=sr`DF`{7uo_ zzujxI`qG~tERI;(e`9#! z(uOCj(}?!Hg+?USO8qGgqcD|JArm5Ycu50W4Ps%epT1rES1#O={dqc-(1m5VWycSI zVsI>QGD}qcp|3o^xK`8T2S;R~W`WYEeX<8NXKAI+;nQ~e=U_6VaJp$2OyCWp88v@2 z!?o=LyB8~dnveLm+OTsa;;r>$2;FxB2{^1 z{Vh*WuklmFBWmrsAw{w*Poze%&ej{qbMvjs#)ZoDWYjEH2R&S};`}7L$mv*Uk-~QU^nSaXvJ?Xf2brv2X z<)7ClIH`KqzohSvh1{RyAGOF7jymy){YQ7#9N5fd0<+{+jC9T;ic9|{=! zyL0?;EI?XRa)Kttp!uN1PI0?^c-&e+StffXudGhYWYX=;7q-xu@n>(g2W1~rOlRI| zQQMpQgWl1Gmw?U9E?93Yc*)(8E67VXi1fHIotyH=Zfj0TpNyEerPR=H(hDnn_s}YD zKGW*aW^bd-Vxz~?KaHY(suXdWo*1o=x8uQJ}Zf_s;;8T|F9`J)*`z0ZpU#xlmyoG%_(iaV!8{8pT8oXq+A zSM~?4HVz~gfKl)H-eC3N3vyf)-}}YjP@y>{?D*| zGVAQ|F?ef!y50SXz`;L|)s=;|y*}Nhh@U`rl9{Xd)c4OCL>hgjH||f4%a1pPdQ8uq zy=d}ZOxteRSWbeOW)8YYQ`dT7YNm8cN-qVUkN0U~Nv`XlF?9Lbx4>Z4d}sUs?!!9a zS~~n09v>8dIyn4p6G74UU2^aXTSyF*ZNnl@#A(q8N1+RRD72nZs6Gb`xV}{ zfQ|6$zkU=rD;uv|UG7CD!`ZGSuI%tF3(I4RdjjVV|9;rg{uQ78BmQH74mdfS^-}EI z>Tlha>n{{H(J$1$2}^%#W7$?gJ&*(>J)G}K3m=Q4!m?E?U255eFQ+2m1#Dr$|IyP& zIvrq=Ix|6l!F@3N&u{-e(7y>5)X#(S|I2{?CQzS5En$zYTFS10YB=!KhyE*-+`YY{ zYp=@)^89P0Pgq91C&LXfu`xBKMXMd<>y+DY3QwJkMn^51V@E`oxgX#>{nKM#iZh!@ z@;OG{)0^a~4dck^Cvhuw)n8%bOXt{B8;1u$j=*65#-1)FV)*0PxZ3lDY%2|;$-Xeb zN}#&H-K?h%?cA~vW`_y9zL3-SPCt^!J1b|=pXGuB$3JzWG(YAYE27c|!(irnYp+=0 zTsD)gdk+Fkw@lps;M1JlcKB=6_tvxw>jLcGwthvZ2j)4e7l_&ff2wAz2ijN1Qt@UiW^5`XH~ zN&DR)-uAPA#0&%59z206u!mG-HEQwqzYf=Ne%sF%wx0=eNtMMawUPICcKyblBszkgNKl0T8 zNboQ@0nfh^PyQNmZ=H?d>^KpBelI+XAF2KtQZV47v97>-$oX)R>h*HOfRFyVg5V)1 z;~7mNKJH$))N9E7bvCB6-p6P6CsFF=8W)dA_swqCn@s*xpN)CQm*GV*8~-YmVlojh znFN?j227>^CQ|{EX>h<~x<dVq#ix}I*8YRGDXQrp z=b1&h4T0=`g}ByyeP;LeG+v?q&*Cn4LKTu-&KGFYHUxGbhX+ap9@q!j(0G!#J1xnU zULI8K!uG<01Jn|H?2V(7Kfu*mDMCe>6N+|olZ9cyVSX~HmmTmkIvz8t$0L(uU0+&c zT>>_Ojhi1kkJ)AgTkq<+Zc0y<{KNX0(^c-7!?`7oO2t|`PMts}gMzht2e!Pe?l%`I zmbmvMaPuu(0ZymS(Z=mha!z=H=(-D1_Lfh0Tl>128&uxm5ij1b)S(vr-))4KaUeOK~rbQB1f>?J@r*EX`Fe$w6>Xc#3Q_CuG9EkgoU|fCgahTvFOI zUIV&(^sWKxh5+#YP6Yq|*6hEu!Zr0R1H;K-bhu0mVX)es+IWn1F+P;&Nl;7 zorYNz;SBIB*kv@bTU@{x>x)4~scO2R!PJmN7-TF9!Ue6hhGS0SRK>kMR#_gxT~RN} zpLYP=;9W#3Cg+T;x32*)OX=5ufj5BvA4Nn*$Y_`oMi;~kHCtJPAH=OqwF~Vmac1|i zW#vG+YU!ax4+xWz6A$gn@riG!<$&TD>Y!v(`v?Lzye%h2ZiCw(o~0Lr%7Zj&UoSQuC#CTsa2;Cc+fE6w%< zeZX-w+)jzxUQ;9PSC_@Oq_2v*uAKIu7~PlY8t%69!5(2?bIyMu4DFmSLx!DZ%gBIK zfqU2oZ`+k{+L-wsZ9}YGO-pIRa_oL##_){2dtgok`NS2%QiLC2AtFFH>21k}+C?sN zU@BOoIi@V-iWh38KP{II@F-yTyGTDrV2o}wjmXi1$t&@#CE01b%IX0%6lD8LRSHYh zmEA6b^IEwyZ3V9_-s#EFSx_deZd-aUE=ObEw@17KLKxhYMOfbzwET^vfN_WE_42Ub zCf!PAtf0I1F-K6N3maoxCf25#m4_d*gs8zyo$CB*4PIHM-pS&j#6>!x^Gy2Mr6yGG zu%*_6=+kK+P=w`#EO>8z_agBv@s`Pd^e^)kV}#e{p~fWCHDH{q>8PIrojr2*Ur1Qb zUxMn3@z?e2(b&jczx+14p{m4(k zkZ)X`{M}43bei9!n0=+Ll~Kq6SVGv`}7jP3Dl%h87>;@ zujGs=>!IU-#&;f6Z7b78`*3H~$Uc`dkP}^I@K8`j?DBxHE+y3fIKou)4V>t#;o=e0 ztnW(s^1~GmF1PE(e9sba9JMzMifnyR0yDvo#h2hord3HV9=f%wUVc2j^fR1l4Jd?W z{DnQmF|lT^82R8dTUFLLYw5Scxv*^A%PbO+==585#uX7^XDbKnINfD~mNYms?j^Yo zGj21$pkYKp;kh@=Yn3zimRnTY7=op@^@|BfglE<*fh_5PonfL0LSon{s(?U>GQo+k zwf&s)mDhl|pc5@@ZS-F|c&|DT6OYFp40Ur_W+SSQ?G|L%Nc1ZXB{JFrRKr{7aYkZ zpp{!rK8GZfPW2)q@IE}Xt0;23$mE}mXd6sgc7@03Tv)OV&Ve`2kti^|_g*lvGcg|uSp@aINGk#+&_ z@{&jR?Rd0&^{Pp_G%jn|eoEGd8E^L)vp4tHf`=66R|8X>a-HS}bbY~s@yrq+25A08 zAB0)et{kenyY~0j63!JZUbY7=h87s&G(E`o<%DA47^B{0Ms-2=kOxhL?jgn3a6lbt zZIb^%iai^qKTY-;K(nn}GMXn*v`XXA|K$n5G_L<-5R(#T%-P4IfEAg6SzT5kdep@x zR0A$}cbC~D+8LnNfRh=V)tXP71%yNn#peFvxw1=kz=a|qntIe|&xwm^7PG(Q1?&mA z;l?5KMY5GfB%K9lcn$tyNdP|o>5LGfv(YI_ z<@Ehn?7^xHUKNQ8TWJB$Ui3m}{OJ(>QW_^ zcIg7$1=X5IPj}jZtZ}ZTKR)(;g859iPVCnoa6{df@Wj^>|15~Yqc8?1XWx9WjMdSp zU@%$*Yj}{ebQk!%jh!>^$;z`8*K{}bb4%OPp%9a=j;dB`lcd#81x28{JNN#nR zS%N5(5=HDv(8I}55XN?1Tzn^(3+!qVf1*x<(fJ)2F1>rDhG}oBwOd>UCClb{bc3l? z-LPy%b^`a}_3XIozZYTrvvT4-1Xm9Q9)!P|-#8&be|tn~TSH9=a6*!P^BGQ*c~!R?$;# zR3|bqpR+Y%@bo^IwgE{46K}!Rw5-7ycCG=R^U~p6#y~x+d^9%w5r#IaUD{;68*QGR zUF{B>&1z2l)8w~GSb})EJDJj10bX0crrK^g9_U~>wCv;qE=VD&Rd){DGh*3eow@@>ojkx56qSBoDWJpEb)imB6z;_K9Nu+e z!J#F9ur)M|j4_-NXSZzf#l?qqt7>@aGpmc2{6vb?B zV#mQB;@*`my9LG_**D|NgIDP|hE{V`+LZhJ0xD7HTLL*_V@_&of}rLI6_a>^Rrru^ z)40__U8r6L03}2VDBZKoB;;&XE`BHXH71;e4Yzo$&83tFWlD5#m(Ac2E3!ZYUPb^; zw8635wM^mxW>W>O9WZQN1L_FGw${DGKJA4kS~K=R^Slnj`e|dHv1R!}bLhx%X%~Ic z&>>??kHVF}=Xkqxoz{56v?Kev^oJ0Y$FZ&ibZ7|ZU@W8OrXiSC`4O}aT`sf?lUDgc z^&z*=&t9%+2Hf0~(uV#?72-B^L$l#ZbLY*^sT#@!h*4QyIGrdqd+%~(IidZ|n5qYs zyaNbO4Oj!w%}V5cfY$YaZ~R3uL9=znGdx<}d>LyP@#r~i&M$D~?)y+~!rf3ZAz9pX zI>ujQZ!23!zXPm8MmBha*^is!0xr~cEZTX;K=m{sbJu_sbwn^(!w2^e%LrL|Z;ca+WHSBaPcv`czu*<#gHwl$<10&qLhI?1QS{8fgM2H+UbpqtO1!c z-8niL&tF4BSMqZ|%BPaY?!#=CxYO^2f*32d?`RM#W4W(PGxW(rH#$Oe!SutK3o<`f zu^15oj1^b)gn`g?iJh( z^AKWDo{fSQ9^X#;leQKisw9a}R$_qDy}nZ4rdva%LB34))Dqjk=qIYxNnwsylN5aL zD(V&vWrLYc-&3VoMMfgo!s&L@xp1Lg#V}!PeF#2VIlkvorqA+Ry^a6`@$=JDb&B!& zvp*@Pjpyx2M1SLB)On#2(}pccYds;)9w{WL`uJ8HNeWS+I6O`R$I@TnY3giDs0Tue zlYC`j0Xu{l@%?kc@mIKAOu<83=7qL3UV~6)Ne*WQ-oQnHW~y+}R?~Q$+8NvtdYzCX z9qena)y_%(g>rUJ*;7pU*Ru3uD~5Wfz_iEHZCGUYINFAWyCJa%+bW}j#sSnvabar* zWHUHzgN7C?Yp%}=h6&Yy;>_rp%SY$;24=z!mB0NiBBlLaNQ?SUj51W87OPzY_CH~q z)(+yu+bO_Nt+z3pg!Bmrg!Vte<~J3?9Gb!OFjq`d?-l#FKb&?3FFYk%z<@LB3WC!d z-+dZwjr)K;5V{7el6?;?+m`(C)OU#=a1QPS(yOw$t{^F_ZE@-M<2I+e&Pm&PKr-Y> zP}xfTlEl95II1+AXHOAP%K7y~6NpMB5TaR$-h?Q-8n1)7Hz!d`Z7(#oWZ>VXrTELm zYxKZPnR2=(cji;u?h5$Z(l%k%{n2#bH{6p~Je zxJz0+E~If9IFZfKO&U>6FtuC($s+D|?;V@*Rzf068J8Ny7XP;sZPQ{oeFtz}i>Nha zeFBqNgUqG(wewt-`Y*@kxW=oB6H0_8*yS!zY`bX2iSZMd77`2U^C7_-WAn3DeQs8< z-Tl~)_MxbalI5ha=({j!Z<|I>sk&8kR^VQQbL*7hCWv>_5s&pOiGKd$DWE>Qc#+3x z2Cg{_+{ZSj_8p5#Vz$yQex99B1!{L?vY$0p5`QJ1Epj8pfe=SP5ZP*maGroQy4fQ_ zU8PlT17#G5dWDg(aw5P=2%dMtSx~c6d`>Z<`%MnbGx%X z{4ybLqxS(9;-BvQDWp2lb$rQU304I~y;MFMbX9nE2@$@j*=k&P8+D z0ioG})BD4dt>1*ROsI?CLXDJpqOlSeXn1#MEpRJGRHwSbKlM(Z4DO`~gWH@dVim%u zCFXg|ULB*(H|@wkG9}00OH{j(N8HNdG>NeZEY!h5BmPTd*WYx}xOcV)S`SDWm}yEDWX+6%mY z-25T&er({&T?!suSBIAOS%Uw#3PJPo1UK=gW7b|-W*q?&l=h7uGukFNmHq)5DEK{5 zwz4#1aUZH@UNXWvqSw>-7F1t-Kgt6nPi;cV6mHqa;o%YJ)d$2oWm z-n`NVT^k2z9sBDsuj{R(^S(KSu~4#*7J0>F2fTu{+7MibF6|m{mRm^te<3pbe|AP| z(|H9Na~SjfwXgbccWs*h5$<#R|*4jm+E zHU=-aWPKVYCpA<|5L8+M2rezg|2S2Ye2Ae)gGNGtvA`o*@Y-UH@uiQ)ep^6vkK3ZjMd5s>$Wv8`S}3D|$N zg+d^)9B>lo*c557e`UQz&dzQ(X5QxBt;mefM8_!RVTAtcN;Lrd-^#IwwkIWsN22Uf zghd`bU#$yav+Z52W!lz<`K`uW2)&a}<*vwV11eW<#)rwD3@qGV=b{$AoeT(oBmU~$ zM@ZghL1gRe!NF)cKQQtKH$Am^*Id1_7mZp9UxQa({5+W*-c<@;^!Q|*Kt^wyj zRYHm#sm^r`*tCzJ!)YH7Doije@`?oKcMW(K0$5WALah&fcPZcBUIVkuiRNjuo*=eF zeRvih9n)pq!R+@G1)B-{d3X4y$IGs~kh=hna4=Fpu=e zb#*0d@dw#9&EZG3P-s7|je$X$M*b~5;T12hn$-HdsOMM0h>~B2f3`%|kN#rZt1&Ujc+F6PgO!8t#%Ep8u@b zE~%gA!oU)iBB#s8r1C!2k(rUGPxwY{Y^$>@4?AXEptD`>y>{U?1Lexto;_u2oBE>a zj9r7QOVWLx)Fi%V4u&-^G&q+rxg*yAExj}(#_Z`eV8|W8Y0B`=Jaqr-Jje;*1iO(R zfxYJo2%yf`LS5}+78c#IOy_M9363YTpzQuqS(DyJ+VaV|bLx`{Db6Pdi0LBS49;d} zYm19gvLUecqh@%rs(JA|+9!^pZtOT$RL46wAVP)uMvw46tW94Hyn@3BtQ~v$4{I0y z<3j(JBCY@I>>t*qA9Ee^Ui^c9Sk+EoZC>p)IERhUkPm^im!zGVuq3AS)m(<-ql2!^ z?|%gN2{uWOh!rBF9vdS(9y9%mvnkyy?diq{6^)+3LvFp7^U&!&3*Xe{>O-2WsT@2j zc3oI}qbGNvKK=XbEFm97pdafYSk0M~2~@3Z@SQ-_e*{~wT0g)9s+OrDloU&$T(_q(fLK%_ODQuA9SloSdi={)bo=E>`ls#0Y`6U{T^i#;9u6_7*Qz z*^^AyJjNCE9p2)fROL_lYP@C~ZdE-{(8HjVF=iQRW%syS@N;X{p^^75BVlq=1j<|$ zq4z{cDg_r>yZe)%tRy<(-KH;hCju9`Kj9t-uP;_COU-3l<7I04gyfeQH(tG2h_#DQ z0sl{96Sk~tyH}7D+H{d}yWc)y+9SCvP2KYu(nQ~m8`eMmmZXwSukHJKxKKY))%1Qv zhY^S3vqIV;#EgZp)6lf4&MMol0Dm|D8YSojdT5b(>_aYnui8!6?UoakX~3LFtV=eC z_o?~YNDUU4=qiw22Mwp`2SyxUB&_}P_fK0@v+Sbe+R6$0TKubci7(CB;4!&*mg0uF zgP@M@U?G8$_biN*q}F`sJ&vF_W!w!lY{Z#V6*M|J*k6p*Qx$ zb`=k7lSmH_7V9v5f9yba{jZRpuzt3S;6W=$YLAz==8MN;MJ+8pT)2E08Izz}!r8Ot z^E49%eQTo&M^Pc9gyeL=#sKlhnn9YYKPH?9r+i@8lC^d($$+WnO1{xTL1B&F3W|c% zHKtRA6fxLnQfs{a9(7~ykKGn=S%&Rx!kzpGCmTkw7f8BxAWr?FOWAmGDw%nFFo5Qe zGj~ILV<-F99ZG2OVP8_K$Zv0xJ7Pq$h(9(8gd6V)A4IDP1p9r|5g%EOlcmZ{G#r=AbiMogK3=e9raA&&OQT)p5q$6m=8O72)&m6JU_} zCoLpAGalbJkrz=#^tn*T{T94rnYYo49DIlX z*()K`?P;YYRY4be@GkI&C)+?w+-2=v+}35$6(dMs_(Er+clx|`PpQ%K2#-8YZSg+H z4x9rlBfi*bBR<9cjEtwb6(LS8{p5LpS!#}DZuID3+lt72B{$6A6H%3 zgGaCenZcuHho@dgK+dH8`t`|9UISM=$k`&mKq?LK(H7Cf?EThQJG zwMV*K7rx(;9Vqq9RfLE(`Qkp@`T6++LNS`cvfwhebY>>_8i2_Nwhx-wcWgR>)$ZL= zMam2HXe9-7t(+bQuYeU(yE#l2G;=Z=gLdTgnJ>g@P@ysMn)GVc)@V^>@}cX zY_t9dU$7?(JGe7?q*^NvlJQ1K$+Sm+>(n9P{4|Z!T*(7u0KhRP0B{Q-#mt6Si6ni73@40NM+#Rkx zg22Cr86O?=M!p&YP?kBm@C-`l@;{D&lfR@+GR=9-lyc84oZ1lg4*Y?C$l$Z<{eBWO z7RSgPjeGWza=bM?MK)>mRn-{gO#i`cwhV-zaOc%3y=$-4oYbDcANKX-f;!OCkYSA; zr}sS@DopMi{k}Wud1I>3`wmM!Q-Tzzue0e{I47=6x7WHG6g_<2&qGHQw#Xuj;b;5m zakm~eaVjOcZ05-wdwG656ZiWGmI@ZEl#G+Zr@MVv)+DX)mqivFSI_2LzUEBV)XZ`_^l1gr6*4(9W;f_`%8GD#ddr?_CJUV!!LmUc|3z#6=93RgFJ~+qYT<4hnN>m4 zTy=eig&-R1N!}Z5mf@v*CtYW@lOx`+_ ztD3}8^l7CIP`!R^{BXZMCyXT%??Z=0jyOF^^c8QO_$XTO;N&`W6+T*aZ_hf}yS}_g z$4DB0r^oPh)Qv4&%V(Zt@bh^bS`)gr>dIL zYK@qQ0m5bczOj=Fl$~0CODSt$1=PhxB&|EHpV(8R=YFnq{dn$MCb#$-rmhHKj9Qe;+Sz~BwgBJ)KRN^F{=uODTFhXxLp3n0g33=Zn+0PY;4;&68~3*z!f z0&YyvLvsYp{KGMmK-9o$`PXuXc0$JU7PZH?uaJdkcs43dmX}J=*Ij!1Q3rSbEf4+0 zHe&bvujO)vOAgvMN85Bhm8jpOA8D1Rj(aeeQy5CcC4BhtrRqyXtCnELkivkd?mmut zRh;~9NLB+A3Kd1qUqKwm`4ip_-mHQ(w}OqzOP{n-bPTt+v^*8u*VXe?b|@Ktztwy1 ze0s3_{?nFOq8Fa4uTpqzc$@gf+Oxpi25jA#2G>F)L^-8j%_!dyq{fPxfR1Pk`;$dPRsYbDO73AnV z@nXuH7jNSWzg=_JP{}Xw4X%&O8Ib2K{8hn}Yx)bVOj&i#pU{rwWwAA?%kv*v zCkOlq`>&V|XuAq$Mkk0`m%gTJR}`ji!hV=wFFn5zz^J{ywG} zcgk`yBPUZQ3p(PJFkS=T(wWIJ%=>D7Y$e;@il6j3UpG^m8M!9^=RJySIbtIEy6yxW z5GD8zuWBmcWeNiX!#6?rd?RBRQs$D5>jBT9)awK~M!|jyy_e4_1J}2W=l)g)Jx~0q z`1)Svv-icwE1rmA{V0d3)|n~yFC9Ew@9jF+km2(ORb`4ph`+vWh}TXw*r%B_i0-wL z%iq9hpRoDC_`%S8MvA zX-Enk&IRFeQQpzN_u@UUPSLtj^J4L>a+<=D-j7ZRftXn(sj(3utKNgL$?Pzg@F1^M zYx2!1@Ul>UYg!{DkI5V8T!7?St{J;z;N!`#djzx8^zuO7gommYTmAj4y|he`ZV}*l z{DCdJpz5ovi9#<09No8}b)iJQ=8&R~NDhdi7TmL7^^w@WOLg$hBmEBB%|a6cyqwRa zmq9CV>~9@@wduHIpZ6Zm!D{C4LK0^8ZhKNti_t~gqrF+MNClpgufOc=K5`c~?VcWv zs)`p*uN_;2{AiwuqF(7zUb+Vf?2Z4s%m09U^>*PP%HH-5}%@{e5ZL_qJ8VyKnf4$|%3HgP*>x98?yquJULTsjm0PGum~L zc80Gdr}E7-y!`xm1;*)&os;;0bV1X69b}5#sk+7Ezqb50E?XOb8IK7HW81J+zdG#( zg1}ebVM_g6@V&`OcRNo(MXYTn%!Go~cWhmO?ByLC?hG^XEebUmAyS=2_NM-ZFjk>q z>4_Oq*T{ddCewzq#-jak?)IkM=o~&dzm|VDDn8jAn4soXNZ8*7YyM9Cc0ln58j0dY zhdv;Nkt?6xdHb8=ool`Qt!h8F#lH!1LEXWb^bL2+;6bml+tA{L4a6^wnA)j|K(CV` zqU9M=lxv7(?NFz&&mWkP>%Z&xt~X<*;Vzq#X|ey=p77y7EJ3567{kcMCAF_=&zYAe zt+uba8o_zPvfbMD)z1~1P9a_O8S+i^9X@rwkt=@(CNNR1aQa%=S^V}0{cDxL*A`irV#(mP5+ZOhbsZ!o2rhqKJ_tfh}HH{#Q;G&m{EOP4e$FYaG00RK_&aT_($`^4^r-_ z9naxofVmCZ7PF8vKN-)gNIy%LBinZ<;nR`=`vY^6xm_PY2=!KoF4pdE-cS?-LHoPD zSGeA=emhfkvbnm>lq4k5x`@4a|My}?%4a8^%5laC>Mm0=&H7KpMST5*!=}4#S;R73 zJQAPwbUUo-Czxhw_$j}qq7d62J#J21|4UyKVr&le=;Ty0)( z%Ex>Yg`4ikcg=4&v@F8XqMIfbdOFi4o(aCI^$eZRC9*y;P-skLw{-VEeKYv2bkH`~ z4 z9!KDc^^v|saI7d4vgBX?^2Ib=k$g;MhkI*Aq;ZGEk~PCCfBE2oh~w`E%@Q;Tda=L1 z@YHOgS!zZTzQy=Sa1~GvcFZtQHhX#nJweqq?0m6LDBXF!+g!A{c{7j~(qQ>kKZ|?n z4YzS{aTz6-_v1e2ZM(#%9KFOF9@E?)_)0s4@G?n&2z3+CngM{-q#M;Ow{m&+E5XE8s;D$aC z$U|^Top)tyyx!FO^@OA?E!5I0TIP_ufQ*(Y|KPhVw0bCWhv$I2&(fH?Sb(>SQgx7G zO~Uy~qp3tv+2%Fc%kWoi@na9-gLC+wirGjt7{rHGXW)=z;zrGO(_h)e7}3M!5)1}-_)HqYOX@AdC)DOMooc@EaDG;mMR`U_}Y~x7Oo3GKlSnq68 z(p86!K}-c;wy;i~QJZl0*qmcr2Xc|7*$cqRN2f0G#kEZ}K^Qx&(h{l0L&x^#xO zeZM%53A<(y3OeOz!bQhkongc4!fn8w7a9t$V&+06$Tt9Q;|ki<9LfFnLUSj(e=iAF z>Hcx+hr6*fw{wd=Z;KQU?=#8NUKk0%OR7A-pCei2H=h*oZawv(| zq1UnR>5*H@lWQd#weagNz0c#iKgd+HUtT&N2c{1ZXaUJlZNE>xY4l4mC zkM*A%XO5{{RsuVQx9Os8Q$u=yE6Ju}!5_jxoRkJf|2|BUZdCgCD;_O;1;k@`*(*~$ z`2i%$m*3{A+K-FNAFR6H2!z2ynfVoJ%Cb|$7stz9$eE9KFJV6C=hv5^1cQgJt!=Lw z@t1#_1csBZv2;4_3n+x7(b2boLsbdHE3e=W3QgcXkYmvMUxGb~OW+B5tK2A~=x&YA z0W@#`H-I=*`bIP+K;k83H`L2YNeX8!K){$}rYPuSlxNx4h7jKxYa!A~stm6~( zqGq`i`#Y2@6g8hfea+UWyLoA%ZcKp&zP9SS=iidO&3Bd{D5%9qJM%7O!*@AAHHU6W)F&oI!ICqNfvueH+c~!<@Bhj?iED@v zoRpPf%s7euO5Me{mzBkkmhq_H4seZ4+hYcpiC`DUk#d_|iGFd<=Sobm`xaHrt#|M0~U~<>pTiN6M zy%AZ-ooy-7J9+96h~~=3d~ttz_>vYmxE(dpy7$M$`;mZ(j6yv(v#+?2Hw^x457biq3Gn4aTDSO@9B}sihlsPaZO(_~jOM{O1M?XrNQ2p_mEQ{CJ9PqUmlmsopvzx^#jlw?pj`!Yv z$nMg`S4sxhYql!!(x!`k?bV;%aS0gjT|VOo+LScjZ-P1CNsv4XKyZ>2&^Zcm|SN40!~ zT%L6K*U(3Db#HTfK;GVM*vmHM*tpGq+)6#f=s2lP67%Cxm{}E4GUxVzo}{Vfy^PrH z;7;dWzd+2IC=R=0QCQ&|^9H4|I!nUXyHwY2c*Jy>=6#?R_;)ZaIYR+qN- zzr<{6J?#=o`H6#XdmT}K?Nsqt8K*A=Jm}I9-{7{`x{rFk_eEPCHS)$zUH~>vB~=nE zwyzd0IHJTy^^uFO`ms3Ys)1~r)V+9C0X4d4{hC*Ooin*Bw)oPIoPCRaboGp6rK{hn!6mr6yIXL#U_l@G^6LHH|E8vTs?VN#yJz;!oT-`V z+oIe41{8yMt*{1TQSGN6+;Mu9aL9!*b~NKOv&h#X0^;msSvwZ)BD5bJw5DPzn~g2R zSf2>{&KKcbci2!JSF^*tDG&ijVe3p_BV&KZQ+XcCcOEvPba%3qCOS;Q{$U?d={)H# zH(4FXKczS3WOs!lC_y2791r;TYicYkU23{IB72<|tOFLsbj^4TO$|bJv<9)O^|Zdv z4|eB~c$W{v7GLMDg{`JzRZ^9w$m|Ot3Qs~sbIDLaM~hTf34lS{H-JH48vCdWJ|3-2 zB|g>5v?pDh_SR21gK1G#rGG+jIbEXfFSD%Gyux@!aM|wiyFBXO^fiTN9m}nSX(^Xp z8&E#;pOvbKE0YQ+xF~DaPh}-r8t_2IOlXZWZVe$Vvd&@6F@E#S4vt*HV!_1vZK1+y~(MbjK+bav`?}$ z7a9Z-%Te~-@x&e!<6Eo|qP;k)=ENkA%-bQz9Tua^jyV|Gvs>0f2!?60;Hs?7@EDl=7CjnXYx4(RYSLG5X8sL@}b>Fx}}k7mhxsM2UXO^WNs6 z!j-7jZvKK;O^xGsnb3$6b>vLm*`8iujDhw0o}`#5oh3bflB!?wNG?qrW`fR@*oqpb z2Wq%*9u1C>Dcm3;0_WQiI1%m}hV9QH1wqyOlw>AucoCS{Z`+JRnJu;e-p(&-K_B_n zo;6HAJxWFQbch0(@2}_MJF#)aDj7?ld{d4o6Fknbf#1ieFfNs{`YH!jS9OPg+Xr z`bpYS*HSo5tKA?;9dN<{(BPELA~glrSEWnxC3%hZQ*##!EhI68RA5pDrt03`>Y49- zPAzN+=U}wa;iqWXJNsC7*Qp$KC_%JvSRMOvWk7P5t0*0AXLLaCs(5%&F>R|CK7-7> zwcv#E~F$iCKr>I?%a zL1wgmWu5|9fCP3ypU#0%-Qq~v95i*G9zUZNx0ES=e`4pfC~tq4QMywjM1Gnun|!VB z#XwyqlsFwUWuw?p9n;X1x96r(bR@$efuTD*0IG*-06Utp7Ge$B$cG|dUzB$1K+l99 zFG=F$KcnlN-Q=VJ#zu4epv6ipUMKOX$8h`dhGp6EyQScas*T{nX<#4}7ahSU*agCY zCPLRC1uVmAtwooYC9`Xy7pKKf*nrpEn1&axV^U>H>!Aew(?=uYB52CONrKsS zJcx7wZV^2Eps&ev1sc3e`GZ`u#hvsJ1Y0W}KZ;8j0VX{@;N9GLRb+Uesa9;F{dNJE zG*F|!cpXkpD*bZzsghQUTC{3loH~HDx?(!lqy|TVXc{(bx zh2k?-pGFd-|7}FD?E2y+fXli{HwrcD4<8rj;2+V0-1Ac(wxYx^c*C)-es=sYC;3D9!pjyvOLz7CP}IyKNcw zcxDwO;}&I>VdrWKo6Z*LT^V<|>CphV?F$Gy9=Gvy!nB6lN&vzLvBn-e$`i{{mQ*pQ zT+>Z4aG9@=R)hb()j-|7Uf^DmO)Av#JhSje(c zVwNE__-rWGaK}}aI~Cf513R8i@2?sVI7U~1z0A)b_jc0153tzk#@n;-i9e>*ndU$ zec)AIuxafAK}ramd0%OJPxIyIfSa=s8pd0_i4W%MO7#<>llXe5p)+U0x2u{Whn zF|!$)YKaVKIRKBRf|+AXEWVXGr;lBRv^Z`6ejzyV#WKe;WgrDeerKtPI$I_lvoKFC zFk_| zyNJ)EX5nTQeqhKAI=GDGN|)o=w*nCqQdJ6}vFPf0EWV@iI%|S+ML-u@AIqf;NWPuf z6LeEMiS_ix`Q6KXE!RG=ipBMI4V#E(Y_biG*L4ug;|0Oj4N+UTe{74q;mBQO{!Qc60tVj%ZqS zkv&z9fbe$r6%dd<_{43)Z~DvUo6oT(=9@Tc#x?iGV>C-U7S84U5{5B_CgprjC^mcb zPK;YbaiVWA1W}NT#s;H{h9dkav|UQAu`1xaI|8s(hx5bC^1E#d^{>|4VjgHQg9JdV{)1z2`>opvh z%jjc+=JzJ^kDpP0zhJOfHPKFL)cgt{bPF%h2`S_!GI5~sa1f^Z(r1_Od&^&~w6s>R z*PHlFvvrzd0%qd^f_2U(u3T3)Edr8{x7Tx~!GiC&4hisSnk`1wh=$N^<(spCNI}0u zDz$wq1?KlAV<@{eZw4t-&(L!($XU_^8(?5%#*LBt%S4~3^U{c?A`j64yaxiAQcl+) ziv&Ze&>=;Ffm0FO&04c4%u{}XM-cq&xq@7LmiWKKze0Tz;uboG%J-uJB89s~4(>#; zVR5q_zhGaOejZf$;w&6q9;7tgc;GHa$9}Dg71V@`FCc=kMjlvZFPJE+-ndLZcan6f z=8<<^u|_g&LPsrWWbwfcCyg1cK{=`qj=xUL715MI(lsmFvvPAO z*6reuz38FO4JQfwx%>)rQST-_{BafEmFFEkr?yWQc#2-I;-ITd5@7Wi=z|vq-z1q! z?4KlasmLW)#O$+N*YNhF9EDR3i9BKxcwn_@;o=nKi6VX783DDTh9~@}qh8}2Co-1{ zN2x;_ZlvS9%6Q*uKG&sFtc+cgjzdCVZGzk5o!SqNeS&)FJ8a9#TpzS0DjqI|OM}%q z&hFE(E6U?ZOpY*~g$WLe7u=z_9_Y{r8VpVr07pp*z0&ab0bo($}c-325)V$Er8Nk+C{jn+~7U5;{Yv$F` znH8A2aFGOrjEz_dcd%B^bRAh&5iTi>hk(QxVY`qsLuHDG7X~)@#TIr#0ugc4iH47? z6U+Y^cK1UXb46l(0U9|_**V@I`I&-a`OF7%qEDGZc8fut6d59s@QAkF(8;bX+EO0+ zSaK!Cra_aH77|N6GcvzNRRcn+RF}m*$G;S!Gv9iq0Gh3t^goL8Z$7wd?1wP(|F*0? zxW@?25Dbi7zy+t;tofKwpVC6_8wRg2~3@xEyQESVT6l zziav-t@@7~?u(rmnmW7$I;m_DqFY8nDS#?#qk1wdU|U z#kfOJR+dj+hzeU}T(@$ex97rgp~qn@wy!zGd>HO^Sbt&;g!1q%Qmz)V-h0RbfDXNyY2Aj~ z3AP7#1t#F5J>cQNn}Ba1UZEI0-X9zHF%DG5$SHM{4wzUGxWGWx7Tw2?saAT`2qaF8!sD6&qUQ*ng7QHhkF$#(O0tl zsLF!v5aB4(`@@^F$D?bT-_Mu3*5^oI8YpiIQeeM?PsGSK1d=vaf>&)U}8DmX_5z}uCdeEs!oftSMI%M^OAv$hJZ zl`-{{6%N8I8g6+#L=Iss}6K zR}~?chtbX2Dnmotv5XVL=Una;rbp#bKel(x=ur;qC@f*9;6u?VTUX5(v6T|p(9oY7 zT_iu@WTT=idqcd_fr{Ieh*YmX)nifWT55zV^72;XGdV4Z47F<>7B4r}pOEGAOB2>u zhnAuh#$2`1zM6Eru(})V-dTv6TSIkMq^ExeH#7D(=oSz)%hN{SIw82K{aB^u&`Gvz zp_NIe51Quui6qkACSQ}eL>4*X$h>HgRKRX>IFfvJ1P_6@D+fH!QPY*;S%1%h`6)kq z&eZqu+X^&URxN+o23)bZ)y$<~o6)zcjDQWns_zhnhDL7R4HNSr+J;gF-&!J3bnoaB z@E|;7$vDjq!D}TdzM^msj!+P5qs|n&S{Q74U4Hb;dG900cAL4OL0?1-9U8vJzMDma z^yFEf&OTAJhkZ+C@`|kbLPU0oR{Pr0mmNVMklgR6JVlrMn!s?38VhKwf|Tu0Rd&?; zv`jDO;*j!Qgli|<-u09#!^wl{*MQW5`4x_gIcb)@0{~R|(s6bko0lwoOO(5^Mj9xe zaqn+(9h)iy06!DiJhIF}pdIgwjt` zMG^GO8@WOBK{doD*jTXbF;%2sUg1V{;6sq$HvYVgfK4y$PlyIp3I;e`R~f}CvQvIh z`4 zUL6VnVUUpu)?omxq6!Q$*pZt;wDF?I_ZFx}pyU~EL?=!X#S_(jCb zewbE#O?dK~Yko>GspYusRqYIpn<|}p#XBEaYjOqbGIKCkHuOH6` z+yYdBiTA`lP3+1T+BXYPQ9)49b_6eDkAq|1DQxn|*yzg6`S60XK5|E>?OIK*N+BdY zc+mNEJ~@uHS*ku5Z;`t$$I=Cf-Q4O`Mvohf2CSp%`RkV|TgQtz{DAUk-S2t|)%U$7 zxr@ORljMqsFg7#on$htOA3*RdNCF_@moaFEqtoJiWuQx}B~^qDAwv%m@+Or?)VHn7 zS*eH89($O(6&nC+*3o*8duedm@J7`R+0$jJn)OFSQhy>bUCoaYaU0>wmhhfPGjbL& z`(0QxmCSKuchekG$dmZzR3Jptc0~{O^uKGl(SvRtIiajZ0`6S>uj{=z~3-ERJaplk)j z%!c?bY@R7di4u+>yC(ZW1a41X&E(=%sI@sQ9ggmpb;x37(f8>?0Fk>+C{lDsc4=*0 z%N`SZ^MWGGTUL|5mt|OPY#5Z<$X#{-*d<9`bj5Etix}DEV|&n!3rd5uRNmT4n|aIJ zFiv1A<^Jk`4W1<)fvJh)u(CVIP=qY9^K0C)49 zT4aBNbw1~*(ft#WkFFs9U4F2LON*gzcqCi*yU#^()p(;H%V_cW)splvtmsqUDH5-7 zT3W0vGqq!N+M{7M0FsT=(_6<=)KBuJ&p-SVwv^w+n z%(_m6gzTm6k@jlpP}79%@6cvpDEdtx3>@&6Pe)F|$77PWuegZ^ zFatMG?*%a)ZInEvl2Mf;CQerG?9k6zF=w@~Iz`EldS32;C2YL;zmGo%cNLHR$S9a|gb8(%t1P|Mc(2g1KO)Lh1$ZYw@7GHa*YS z++C96ms4VcKL8iKfZtMRUIN|fzwa9K)YT$5vt$D*DrhZb%p}Ydih1t-kfI*W|FU~; z|K9QqFmv$kdGJ!t-F3b;fv={hqh>efo9Ir5P6MRDEKOctm6GtAc#50JoB1Ef`;GdJ z`dOKIxCf1EVQOKg=iq}2g-nF@ggDvTTDwDa|6+EDfd6Znyw>#1(nd3l!J2`mI7R*7 z2W~D$E^01A?k?`K_g{~qW_-pd@{J}WT!9Uu41Qr|eKaP2QCTz0(~PnntU=_#_k-}E z@M>D~AJPW#3S5NnroP~j$Ku9v#G+z&N8_P$gZaoJ4zwc>{!s_<2GOM0y3<{uui(qB zh#YK|DajTNxwuZHYLh&jW?UrEOUwR%THD&qwHYD=x>rDL9M|)!smT34?nue0t3uzr3h6YHd;Q-uK*wvOUErAOC_GA<-{e%4tY6h=)uVY5$@K~mg`a>A0nKtr1bTlhgDvJYhP zqGqrMfR_#C50Z?}7_ylI8XebMn;E_tMnC$}F>^vRey(X}Mz8xiLOa~{YrdN#vG9a; zXizQ6cU;Bgl?YC-?|^qe*ug1@2g}!^=3?fk80)q?WkU-aFa zsQ`}K!O=)1qmDA0v&}tJJZ~=-dGWKxWpHAxKOc^; zS-qywNP0#O*_YJh{X+itU%HchrD&Y5r-#ie!74ma;f}Ps7Bco zw&{*vV1XF8G*SDMx&0JPy-=OoS_^YJ#lz-XCg*9el{jzK4_w8H>#*_aIe}V6lWVFzj2BuL_KI)^q-JTu4;wuj&u#Ck9Xg_Zb|nVe+zATUwXeEzH+ull$+k zN->J#gfv1&HgoKu#r&V9S%p~z;8HKD@Q%>UZoKb4)W&=JV=bXBFD z1o$Q(G9w**aFlN^+T*I>GF0#0Wb7g`55oR$$yKu6@l}~aWH#@^^ckBWBhT1Si@3il zV@f&BNu)2kkd4vKB2YrK2*Ci~E`ns*nmyFoyL0N<+~IwO_j#Pqsm)PhgXC5%$>wZ~ z6U?|xr$Q#ZtCSaKs2yKt$2xc z&DuXU5b8>TiH9^88&Vw@VU4JY$y0kG+l1{Ib zq|C(KR|Pb$nW`BL!uhG9?dBuRm&67_NXDO&qkmN^TlTHh8sQobD89s9tTI)xr2+yt?7}>@K2-|>JU-Y94OeBp)R8g@thT+ zY;lH4?Jc~P6F!JPPKzanGC8C{A~81zE~AW;@09ClC`jbO6%dI_g49B7Q7Jv1s6AV) z!(eAs!o-*eK93aN#A7iS2{GiqZ`yB=2rEX%ic6o6soxOhjBFT~PfE&ruBkUEFayJ6 z;tV}lA^!ZG*A(5`tD_#?FtOLHOu50fP(_r&a`s-dc}&szNkYcBf=--Pz%@#daKm~B zPVHDG?tWay=(;<+&P`96^MiIJ1y*AdNdxNlJPPHSCK9#8o6=BKE1Mz(&E_HL=xd90 zj`~^d`Q7uD2~Xk=IMH<^M^Y`Hc&5P(1{AyiDP!2Lp!@fI9!CYGl}g6=LsNcY6sTSt z7jvEJ*p@$6N^Yj@Ll^3-zr++#{7&s|Q*Dv+C<#Bf2Jswgq+%^WEkQ2vBBxZ- zDV#K6W|j$q0GIjd9QV=s!sX@0-C>^2aR!e+4Vg(Zqm9t^$ojfEgt_c>(IsFbGS!s% zv{QUbAqK2?S+->by!nr~8fy9x6m!;6gfj;!CmHR>?dL^{TYS?#8_{(e8KClWF@-96 z^K8e`U6oaSo+2%q+iG!HWk+IP!-#pKdZR*w`fNjV{{a|ll7mYOBDq@UP`*)MFY?q= zR>N&weau)jhq@InNlB)2xIDPX-mvzdV0m^OdShTMV&NO2NC0rlAz!`f8OmeQS8{QA zX8w~6#3Q$Rp2ZkteJb)r>bGQiO5$j~tzf;L;H!J_HsbN>IKz0!SFzfVT>%6P`f~$! z^bvCNOFX|_?gnQxdQt<;4yhW$_;+_?*UH$E(E@5D9j5kZTNxLQi6`J$E9p@E$<(iN z{;_Avo^UK_Qj*8OKjtw=(%naM{UKh-JT+8Xv9l;!$DioZFG)D!h&_u54irOwA(8Ww z`+tDFfPGbT65MlbAcKsko+J9yD)Zc0gq)j=o_~$+*Ar%6Pjw9Il~=n+ex?tLs)mSP z`e!^AEFV;3q~Nd#{JsaPLY`QXjVS~W_e`Ho@L(`n)UMcKBIJv;Jt{#hYIj=#c!h!` zI37Tjm4n{SvN4w2mOnrgplPv7hJ$gnQpPT~@_wumWMI4mhKunk9?O3YcB`rvs&Sqr z-q9i^#t2_OgLf_@l!Gu=plR@Ao*pEE{Jm4799esa~${VSg^2b;<3>)4j9A?t)N*`u!;oz}5up3dF)-oG~``@Z@}Hl3y~o+}R7$W;^qB(ZFiL=J$1kbqK}g zwERNGM>YUZ$V9%gA2(`)*+CR5(gP}HK0BeAutAyJk$~r6buT^nopS~A5*e=rfL`_* zan~@2-=&Wj$yK57%U~_x6ht>FB5L}niKnD?$0J!y!&c2 zS~HzkL_z~cTw=L^xGt$7AaTK%DWa9!FMwINq-@1kblZe;+TS%U^5FA3`X$~)kZ1Z# zJ3Clw?G!xg28nd#i)=z;F<&j8?KCSPOm*5{|C9t;Yl<0NE}Bkk$sCR=T=lFnfmIIi zWQcV!u*nK+SfuD(!qiEa~iCAF9g+`HxyaBemu~^^4-$J+)N!sY}&} zm;@Pad_6fg_K#OAY3;Vosq&lw6?MhK%r%AGgZ_zA{WI}sW*7>F+NBcR_YY(dg{&e) ziQq^MHHGKq4?GWWpDBobygp>UWtpwLflupuAL^5|-G1~@17xWInCihb-v>Tc@B!a% z{3bq+o=l%ajs+fFARa9eRFy9@*JwBn1UN_oqw1k$V?3zB`Vp*-buntaCmg3xb2-Qa z%nUJoMOUzvjA@YUt(*+>60H_w3_c}X^n)evU3@*_hQ0hieWnf&75j6J<0-axoD{LH ztCvqtSszMW11aS$F#+=+jQ6Bf0&GYbq zP5w>eTOi_i()X3&IBL$DXysgLiZxS;Y43EK8r|5o&)-8+7i*Lu@qzQK0CR>hrIozB zk0yqWsx;~8V@d@FuAzIy)()=VSv2G~>_H%xrxfQIaf-O!dnm{?w|$X_Eq1pAps9N7=;Kt&!ul%y3QWx^n1prenWc#j}J6`1B_s(T=2fSBW{j4!nG=j(!=nrBe@vY z$5=+c*0|?PR3nmguOA3ht5nCp zP6C#n;KItD7ZAxFF)$69i*~o^1?lVgcLPxZ#J8A@q>1MP^z~{gfhc=akF3dO`5qX{ zdNoW&hoi$}nVMiih+_c|C82uUXO*8wOOgM*ES5w7bp}&Q(UQt9V6z|n2adcu4hHA* z_I-S6@*LcgEG=2JJK{EcvDX7aiSu{k$;#5V{9AkrRFV^Td;7S@ivk*%xkvAZt(=*f zsARi`^h|T2m!YmTLiJXnvIhJP4B9=R8Mlvs;f|r%z!dNU5B|Z~ugkhQ0lanL+=r3H zn-hrv#Cko}YhQ62(j&+Z$re6|;*;rMz4~(k4{^STS*>IHFnVQA3ZM)-lk?4VHh~mV zl6^OHeh8CQXs+nw%3S#Rq#{UOH{traL#dSXxeq#jmU9w?Qlbm1qJuIngB$+JUatpb zD0@tVqZwTEenjPl_(351CwHZOdGyyk4Vn{mh=pvllWX*Bla5U5j#OAmXrh}<(Yzxm z7mrPm1Eg0LjSF>pt?6$0(_5L@4D0X{w5FRpO`=5643ZIZ6$?Ai8_>?LIA3Lz?%2O6 zEol6@W36Ags-Q?V$6)%FQ_m7X47|f8UJxod2tbnLcTCcRKq87g`6lv=vD|#2x5D!HM=As zqhL!K88~U|Hey8C>A7n5Ew^#1Myvkr%U&~d2y)=^v{of6(6Sj@U1uIqDwG*p$~ieG zby!w#kC;;0-gJ|=(C8*2&VN=WsI&_l`VeL!;ek2 zhF#>Y3LA}6aLX{|Kr))kQlC{4Ihm?u^ras*tTIdP_AQ@iL6)5Gt(_&dZE4vgwPqTx z$#xAtsYckblV@&G=E*7fcjVsFrX{lgE+X7e!4T8RlN>2NqVyHy-nQH9$dtA0w&%Y| zt6pCh|IJF6vyaZ@7R3Znm+dkqQ-73#m2=9CryfEVzTati=_ zApW1}W}u+(|C68ImD6b8Ty zjToGw1OpI+Zi@T|7X1ZR;{H|6VBWmaSNyB6!@ha_e*>N0#!(UeFR!}w|7aetZw|=Y z{#CmE+Wfz9SB6kfZ)X3s;P(EbA;7)S{^wQa|4-{#{YR7kOZ)riT@e5U;W?_j}th5p% zyKxe+Ivt8mgRj~6xg?tS`|p?EOK8u4_}#c|_uQv{c+K1vh}GJPmW=)xyRx2SeemdH zH?7M!BdU3VfsgE#ieZ7*IFEy=>E)Q_;Y)X(122CXFjLxkb=E1oX03bDZyb^*@V!#x z!AG6;-%X;CIy`EQ+-7dQZ@0oYE=QA|)-9)K8zK*6&?52-J}Y-*q^Q2Eg*NucitmeL z?j@LTSFyi&#ZtKT9iv7gqpm!?8P*tb>#Lah57mp$IgTXc*ePXyrP;qqygR;ky{?{W znffs>YuCmr_3~|-W%jQ)_QG-xH`xWH^e2ykG5Z#=0i@gu&CCg$`aHI7E4qbZA%JDF z>`}wmEy$kmnY~v>&Tg4PA32U$Lo6V`{K3Y!!7>$4_l6&DzKDh=iAkR6u2aUerTtZ7BX31^4W0{DR2&s=`qsHET$5Kl@BUf3>M#$_nstCVM6%1VFi+m2(d1mW0Y02mJbP(OP9a}lz9i4aUKLnR|E1eD1yO3I(7xnG7HR?Y`p}#@$)O@`<(c*<2IdT*mWb&UEEn)vZ+8`;RVQc+QpIyN^Cm z>BT*-HaQoeEyBCMyMcSs{LR$E$)zc_2!N^v?h{sBuXI%Zx$oZoBnYoSvKPv0B=h@b zvhd7ZU5Ut#Q}=jC``GV}ino}me&H{e`2{QR4dH+KV%e!z#RTcYD(d3>Q8J@mJ|$eJ zUHh#Mta0Og-m_IHy}sG*8Jd^jOw*=wOs+0ILW^E(eL(fe#UX0oxAy4$ISL45;WY$8 z2Z2D~&*Z$k{hm2`$->>AZD-DV&Zsc<%u{Xyj0agpZ&&zfp0S(WaUgHV)zx@dQFUYL zy2LPYeZu1lA<*#0%@2j2kaJ~I9nB)C(iTMwy?>5N#MiKK?ge3qRW2!?#6GGecIZw- zSQq=NQxgzSP3{Qbs@os`B)2<##$S={;N#ORxuuESnkIW=7t-}y4>9zQ=|g?i+Ab4I zzW|Sksz_gx(YxOw2A*=(ZW*k`O(=i%e%px^`26x-lpO>6J?y)ipPNo9t+Ou`+N@a) zq*%UMJEIBv{1x6@YK9zA4sW>RV$XAW#C_aQad-IL#M>jD1|aT+_2+AIi3)L5RQ~A+ zrgvsk#QO{Dkd>5njfxKt#REnDt8*8E&+-bFj=V7Pla*rBc^hA^Oe=+uD=@x$9Ji=s) zdoD(gRa1FH}c9-(LAs-Al`#C2Rde?d*-Q1vwvu_H|O#B+q0)S zqo>s;%^rcjJ?u`^0~^mXEc+UgWsz6mEp3h6_pR>}j2A|`^{^s@YWO>b*MdXY{8>X< z0382tUvP*Y$bxDCc+KXvt++|{3ORciW!`@EIsF>{AoK&EMtF|j@OX?p&)!?pTkSxA zc*%JnsCI5LTOB>idJ{vX+1AkN zpr_~kr|%CHx7HFMTTcHhT>2w;2GAa{Z_E9HRiYjOZTQf0@-y10ZGzqh0*V_CWD#xX zO+=M4So2ruJo!(fOSvZhTJnFY{MK&B68ooh?5Vm&Ipyzrlsb|ZKb+sPUU+DmRm!lv zNejKj5B@yO5`UiZ<0A%c1t==te{T>N$=p@`_*+HscFAMUz6w|7xHbn#&iQa$*=A?U zbuhEN-F)X@kM6BR(ByXu_w($?7OYs+nb-?arkkk`gB~v=N^arqWk)IWzj+z>+pupJ z%_Na?qk7u}HP4-FNJg^Oph=e{OvMqr#?U^#Jug>84<)BYZ9dB6PXR~?pE*D?8>$E6 z1YBZ$13d$qO))*Pi{j|FE{6+urXwYS{RDRYxChEm^T z_=2s7(J9lFSr?65A(`S^jY>vdE_W+gB!5v~+773Ab&Xu}W9V$&zoblywwt}oDwnq3 z(!4SO$Q#Z7B?ah`|05OZ7e8bmrceKp5{n=HNBaJRXyG-@D+6-PywJ?sZG-DK=-!va z^gc7YvFi3%!GQ(IRP-kaa~^cPE`HE>#M=0(!H51EGzzK`-?#Gx{vbp9Z_y|iN&w%b z3k3eW4eh^6qhKZR{TcC(6d}>Rr6+?HZ>&wPuF8pU;yo*Ug*a^iHLTiKOU5CqZQE%2^V{FK*pS{yKnji$1DN`?O|h}m{AaQGK`_| zRT9qMC`elb#g`0=T}~4^DKH9>0RDcSG~C~EfNH(LEttN0!EbLAL@I(JNuG!FdIm46 z>h5z3ozNxWBJUrDE~{SO=N3GPe}gkH3KAAUF(tzym(v7K9F2lFEp;3Yy;p7B|beIW^YFiRF_y)FF#|2B@B*aZD%{4_mxx!o$l{%x~6s+^mkVwj1IxOVU4bC9P@$lBt}e}m{|eRIM8pQ zf?^I1HTu?wNsII-7tu(3uRR!6Fr<{BY`Z>+sG3o%8@s3fyT?_sxD|4X(uDw_q6~qq zn_$xLEdEdeMCcaDzg-0U*C#1u7Cgz|vRiHT3=IvKsEAz;4}=W*WLH)UgHKWVGo*ra z5vewlPAwCu>JwJ%6|UB7WP5xcsmp8rZ;USS{r~Ut!s)*jqQ%4(Q)gA8}4u{Xmh(7W5sl8ZUN-8Ds;|*0CE6JVqEDDTSPXta?3(tV586C=T{$r*z$3OBU z)#b@(S(dS5(vE4bNJ7`_uhgfH`;FCe=m-!{SBsheK(1MZqc9o61jq?SUL*qdRc$=@fIgbJWjf|ltkt2b20x4 zMKF{=GJ<4OWe2*OWbw+(;8*85JX>-Po+X>r-QD7kW$a%6neV_i8R@6tmsNH;QU@3O zFSPQ)-eVQSc<>eg?Z|wx)?EH1>Oc*m$*Zo>15#2gWH}KeHl?s~_&5dnRlL+lqNPF+XLQb@l80n&TKJd3S|U4{VGo+0$Ee z5N|wkLqY)wO0WP=-8`}UXWUkQ$`H(g_sY`W`;yt{JN;S z8Y~IFhZiD1+U3zh)i$8`3<2_xh%Qcw^IIkAVP`t?KNO|?y$q_}9lgJxD1e9%eeO&e z&=0;RKyUCXK%% z{X~F-FSP*&svwL2p`jBaK$6!X|3(?`-#ttk3;Gh*8}&3?)2O}yYZ&ET^mCxKaM?m|U0K`&y=%3WTVT^x2%agny@JT}4hahHfBHI(FivV??+ z|96A+?~Nd-lpVGxtYBCXy-xS%8VJZ-DW=+m}4z6crgie^xMV?NuVN zY7bJtg!8ds##rDL9nS~oL-O>M6t)^3yzG+p_W`Pmd6JrcdM9yQ@_xv9pRtuG7Bc^D z%;SGMjcM4P*9c*+g$fSa8L*@S`P&=~FzS&pZlyoqsWww;Fq_tAy)8QICz|w2Im=aG6z@mw(O4mj?eCLwM) zLM80AEO z#6!81sBzl4w$5wDO|?zgXx3AY3gDAll9>w~?zXk_aiZqD%K~5RLbK}4Kt4=M_LF6J zbx$#^O?#(wkOr1nDD+llacpr|Zf*nzZ7gI9T7{%n)CPo?=DQhK5d2`{nHoH(r@e&} z1-`)gE-EK>z}Q`FqC%T)&0`Yg;bG>JR#(T@z!b-qT9?q&9tbmcG>iuB)}D@!D{)0J zYw0b1t%)aMONZw}PuW)OGjv@>k?}$^=W=CLQtw#Ro*S)vcUcg{{f}Z0i24GA0>Vo2 z`~Qpu3vis!A`EtPWY?^<$%SWe{|w@V=e0u_59Tjz@@Wsd9}HOQ2qV-mMNwL!OLVt& zu58-0+o2+bF!%O4rTC*@RNh0>bL*8`bAppvKruYSaB{{R!yfG&1v!S1xHNcYkz;I$ zL$Zr!!7Md4mr4%~s1k>gr^x!5TwIZbdm{krKUug3r0!4Le#J$I;TO zTsL#Cvc0)LRsAlMDp4TpyYT5PawwHcx*OcQeS11EP7&^V{pr)1;A;6%_ZX44BFQg} z#YFbKba~m4vdRL;NkzUp{9>*!Mx5a%oYQ$>3#}U;1I98FEeF95&ePzIK;aioy>_{=(C&4P;}lmtnyD$Kv7 z!(UxPTxnZfB#%&-iM&q_D9(KQ&Bjr&2k)kgrjfT)EdZY-hERXXPB|u!zgtHKlh``X z18+npR3h{+lU?>#Kq<#X7!yu=@<)WmTFBvmQH}1#S-jGfH24)p3E_faE;ny`q`E@bskvh zu#9^YK5(sXJ09YXcV{{_{+7mu-M&`rTb1^ZesnuXlgOkKk+ka4$lGcx0A?13?rFEy z(SZAQ`yWPaw-O*VU6YZo?OCw)6_}z9GwjGx+Z;E3DkcxJ+vv9h1qpX#^<`5xTJMxLpU_K>xc+r?DD1yEExpKfqku7j_m;TqbDkLCcuTssLr3g3 zlT{N6?$4$P+U35H=-~KGS4y%EYzJbaj?%z+G>Uz5P6LFZD?;W-G4(OE{A38p@!G~& zhc2DVU{NmI)N&lB>bK;UNb8Ato5lE3F2lGcyW@}joGS~MAXQRk&_1O^HVhnQ2CTxp z)Cc|)y&vycmb=`B_PThJR=UiJ_wcoWiz#(XMbxJRxM66ADP>gghQWPbjao;0g%l&P ztG6qn!CjWci^tLSUbaf;w2qS?TIFuXDIKA@C)oR?n~{|4G41#Iv&dIKbw|*qJX|dN zD8+4vh4V*&COYM!fz-D77m#TW9|@%f(CnqapFr4+!015a165%nvr(NB#;m3Qz#iTa%`0j*H_QiP@f6ENV3%lvN1jwysFp9h&vs9AS^u-IM7Y0p@5OLDgcsFB^ zb)Fe7>(;KxoBU zvk#P9V8g-7CtCWT10?EAQ#L}xs)o-aPv41qDx?{^Vf^a zGa*1w0|ZF-U*_{aRUutUj0@tM(7JkNfRG03G1XmoTFh(z8$lO;;>F-Ix4^{G-oOf+ z3T84!3$QA8B|zxe7l$6Aew(rJ0LK?r!9cV*z1~8` zEbT2!QEVZYns#SP70Ot{Su?}Wfw)tx!#O50=6-oBSZ5kz*vUXHIR(nKtEAZrk3RfX zi|Gz=e?i;dhR&js9FchZq7uE7WX<6e%3uT8ARcrJn(|1DCgZKXNgW|j$erCPR*uER zQ>4NEBad^nypwND%I&*;h}6fB3})bPu&aC=c~S{FkEUI7D*5CXqc zxY{s;) zKGQ%zzYwcO>}kSt7figFR?if({KFzV2`p-xsD=jp?73>k4n-sy~|h^m)@i z-_zwh?W2v$g}qK)z6zod{Bd1L9+%FK&yaB@&C9tEOhZJd<=H!T7whAdJzxK&J=&ffc=j(CAOz}U9+Az0 zU|FP-vKp^tVBVU?)X3ts;ZB{;!O!h`rlU2@v}a;>!JC!q=|M?e<>!U%PsjHT-+mqI z4#^1y2tWT0aPn0$8F=VEjNQBlY(F!s*HOn_ixc;br{7n86!=Fi{pg2Z@3WBFY*Ode z<#fmvQaO9k1jc4CVRZEgfeVw#OX{Zg}PH=d&&6kbYX3mTZ<(=oq* zxQ0c=dS_pNn>DFob)bhcS=`Rq?|c@on#weIN)a?9@Cd?J$YT(ZhaY3 zvFZ5;`g_NDeDW`gaT=YroI~ep{@RhgOY!JhEMyz?e@CdXYmN`(fjZAe$}I(&x2y8k zluq-NU7e#!-QwRxVHaJO=_D_Da|XL=K}g#4+u5 znii$R&jNq%O?}|5dIuFvI^D#Q1JCuOfEze#`4vxJm5WrO7OXL&?WiiKF)y%DdbJ@v z9WcNw)E;h7WwIv~F)OT?szfqMoV>Yf!bF-ScU2Td^1ciV=rYc8-4pAiGjSfhfpUso z=i|C6DU)B2C!7A9WsXu(NhEHO?w*J5po!-*cM^LRqzKwY$1_s-6k!j z>E5Cl>^i2O>s8#x4YsN|SN7wZ4YuF=E;7j*Jxp-Rcz@&7QRTo3=@)90KVE4>ZMQA% z#h_T4%rR$O*>tr-)56xE_NU)qMvskQyBx(vi#E2tV~4iGo_Wj>gF~@B#@Ho%TpSS4 zY@fDD!1EYafDYzZ%YwiKQy3Rq;&4Dw4?q7iXqp6hOO#WdD7r4XYnlP;@o}gnE$k@VB7?F*TQhH{I>krylMEy_f2<}-iJiB@hN>XOVd%tl6OAr^+caI zSX-*!a|&U2XYQt!Jh7@){y1GcSR)%LZ(s=Mz`&9Pb2fxAxPj4J6hi1G^q~#g8fWHN zP;IlmM;>6=BJDgA&ZxP5%v%bGmROoq?4Dz(tsFzhEbPFnhntvkxA@4gPEp?4Ua;{d z_fIY@0@%x$3#Qqm!2wPkLu?zCEes<9siU2P>pr{#?h6&1_Sbwj>jzaHOgpp8F!n|~ z=k80XQ*-_;61$$mTZH_mZwl~BAoRgIURYWp3uVDhdva{18%DK|&%wj)j3Pu`FtDY2 zJuyC870d`NFlK@7j(IbdZs_$;M}`^S3c}Z|w04=Fya3xThyGsUX3lN9!Bx9WMRFh( z(ge$&flIX=?c2aV=7$lvbi_0R8GK}u0$!7G-GOerB5JknTXYqGgE zhin39Wugwc*4Kpsb-_IX7HibT>UBFGQ2cNPBbzi!H*8u`iZ?9l zlOTvZ%;=HE&!CI&5bIH)DPFVrw}{YfW_-2>(!g|DN3d$bVD| z5+I8(qGQAXb@Zf%-|3mQd!5aMzXIoOvzG;ZMAtfK`_7%(@T%B^_=Ubqzotti_F~;A zX64$s@=y6h;z;ej^b^lt5EYFG#6Gp1Cjq@Is&yHvnpg-B0k`=x?iK-H({IrPvQ-Qr zo|sTYz=>fx@j8gg3mO4l_MO2HT9ZxWML6>b90LZnIGFtj!8NMo<{}q~=W*o|0~39U zKo4~}a zH=slN90Yu{I21M~HtF7S+1cM|hjtOh4|XhON0lpW4aKTJ=}K#Ws5v&wT*TrKDHx+v zCby{k0ndxIjFhRR-MKbKy0aHWfb0t*Q*|wniZUGXM2`qPQ)U2Tf6%pvV%ac4cr8Yp zU4F0fIyI;4c%Ihpatld$J<6;G; z>$Gq90d2f#C;Kgzev%oasj(4I;fsD>DkED_p(6+%nH%{r7tr`=`5R_0jl8zWUFnaG zmRx31=j)w>=S{aLqc-Nb@E2WSv`tRfcR@e-L`LvDIE|)p?|FW=tjm!MRI{L*)*dBNn}6S z3{5hAUPSiejm?hR9v}P|7hrsFsXp=PC;zBE7SMkc_Tf{~@r@JT$BnF?#VMVTjK&(k zau5fYgz4*^zv$Vb0E#UU4}2HQVEbNI9o-^|ik5+88a4;=cTU%bH5t3)Ogr1tqQ-Eh zFWeRb8SV_1KE@oT7M||>W{M~GG1}eE{|Z^fQDYkyCOh|7;J)oB2D}PF7yGnv(UYoc z$(CW;lV)>L<5ebl>M)xN4CL<0f(a6d`;!KS5T8ej=21EtnB^9BYkt=WXIW&ct zO@+g6HyA$qi~i?E=E^heX?1uy?6VzW181fAI3^3-+%n=JGry(%?~T5bCDY-FymRp* z;@kB*`ho@zlk*riN&YD`%XK%&E&3_-HrcthaA0p1viInS0ktl#*wWbI8x9b0BK1eR zb}v#XbX4WUGIMxg$SXIl1DL2C&ND?K&F4co%Y{IBK8`gRqa#4EVz|aphki3?E8AQq zfI030XmBQ2Nw{Yxms8ge)%vTYMcMagZOt}5fqF1;Au;yUDazfwW}Y3VHQL0#WXhch zy9+rJZr8bzI&aeWns`Iw%iUzYk$W=2>(s<2O@Cd6%x4$Kdvr^#wPpqVT||eH5vZ)AeqYXm8!->la{e2Mb8qK2^(aa z(68C~4a+(4VGkcoDYrb*#?!9F8%+6|4t zsGRBbG}uKg#f9%pv}pbabM!n{@bfJC^8}nPdT&}44c*}`1xJ=_uyP$x61YR_AN@ic z*%(e+r@jboyD*;^#BROLc#>UXSHrx;oU_<4G<>KS)2MbUVvUv6xt*2&M-yfDL2v?=4zbn<+ruJH9Mk6$PEI!Z`d`yj7i$VX;^NW@KMfOL@o zf>SszYT?205I6l^M>d<1jAnO>Dz<)yd+D5Z(JXB{?~?*ttP|i15+>pei+5k2ImH&N zR;RhhEed@cjd-*eLdI2BIH7a7mIy~rrM9@qhiiSXMwEh>o};^1u?`e3eke#Ta-U8b z!SZug$(&^lrv@r6d6I)Oz>-1cc?LFt)|>%hfCZvat_;y{;A!n%@a)BN0;J2#zo*-V zG9GcY6lYh}g5B1U81*rGk!A)t%WfmC#+kM(raC@)Z07fRqAmmZRy!)4U-y;C#WH4X zrqR`Th^!IuJu`_j&r$Sl@;{Wb@Hx*@W-T8ABs7BoZ+nXbId?-4DR+a>Uf~eMWp+8P zq=$H835#F)qttltM|5P{Qtf!!q;dJtXL+jkzn7&LbKcO)>s~_0EJ@^GdZGk~{Z;L* zj`rpilGC75=vv6=8{HWlh!`v`SVVF!J^pOX!JH=|PH{}!ocapjWH<9~P_?UWt!+-R zj-8Kl@}nxdhU42;KdHS-^8b{J*qKcU#JxJPyFKM#DR@6voRld4a}sG-hl~ZlZuj5; z7^-edbZ;!`_@uFxDISoP?_GsyrBgOih#uKW3Sr0>8lrnc^b%3GMUX#lv;0S91^VF7 zcCH(zW;4z6v6s?_F(Bbo2+t+cCsXc!V?erZyuu5_s-)z_*!WG|IKJ~Ya&`6kf^nux9{U+>f=Y!^}W5!D;9+U8b{8G{`x#%nj#-u-n zLKzepX$n3DlI)8#%^js!AP~m z_~%KvIrnZ6qehULw}p{6ZZi`z%ipLEJ>xnIEN)l05vylR8F6@$}e0YZyS$}(dc;V?;Q7Jf?F>kq!#%Z4T*Eu!ykNj7QOV-+dE-V+p3+K zXFWZzs&u$?PB7Nd_%7wWRPhy>R%0$T$6IuJps^Nl;~@?1>T8g`!`4SDpEPkUt`}l1 zH@mR5a7-?xZra^xSI~Fo-mo$`W;XO(q%P-EyZfG3AlCZ*-RLD>$+sl`6bOm%QGo2V zI-Uqf6S$Um%C1 zNv4ojt&RRZrJ$ZjhSSFQtc7U_`+4Q+%MkDElxQ-2LmIUt_WD9eRz0F;w%2y9ALr}h6#tI5_*vv~wS!s<`ux5<#P;M8zHUG6)&0zKs^gIt0!Kdenit0iw~bk~#8$F5O7s?s^r+WG;UO9h4FD`jDEuD8 z(coG76~IjQGR~97A-a%SO&;z5z=nhjCsp`n*jjQP9p2P-lP6b~y5n`}Z5vL-97Y#S zMY~=V+?}Re8*Hqp+;8l%7tHZiqE%7uPp^zWiG!YeopXZScZa^!Uj3Qqi@+ z?woT}_uv0UU$HE^lrP>m(1XET3slW7>vOT~E#X;R;0*7xbLG&8!;DZPBP+2EN}D zJYNEG521!Bc3OZ|n|V*az*;cuI19NFA}#UJOWkK9U%upp+v|zi z>$WH2y%eBsT;X+Da&OAOWyo>OtL?A6d#(HJ0GS8fqc*g`Q`dC$ zU&_A>kPGj*_iH@0Sm(FPy<_$4#H4vcpWe}$+dGYE6O;X;H_PTJlWLhR-trBgP<3>c ziSO%rCO^F?6y<&;aTKieFadYSu6o)b?y>iJs_Nlhb>LPl8zgoTIm(sKTFVk11~1C} z{`_mxA`~d(79B6UdJk#gTOT#hW(oY_d8Qnl+g_(}J*3`-nEkKcCbc!oZMC(_Ep}3t zJ$rgfzq+Q&P4HoD(P)QMFm!X1%&E_6I=11_*f38XUU{W-+Q>|;oKc0(4pB~SBWx;b z@nghuD1p;w+1LN_M&>IvU9*mFE9NpykE?*W0)RT?>qowd5j#?D`J9QxSiH$>h<~I^ z*duqY!A{q%z5S^-6i-MfZ<<}Uqxrg|=0NwU(O0+3j;+?9m;0Gf+qZi0+A%|t+%Ik& z57+ZcsT=BBLxkicdxWEqwHab63^g~O|GFO*?V}f-toxguiPcG;f1h?+myGF-OGt`& z+A*ccIBOg`No7;tG@Y=Esz&H2iA-kUM|PGCm{eXB^~?Z$v_qtxLg=%Q-;qXVHh6Cl zyNgzr&odZv3e6Nt9UZ?`8DzwgB{&H&Kbb)ah6@3;GP7;%7Gs5vKe=zcQgnDRD9w@X zho_FP2IJ;vOi=pOFpy-}Snd^>|4Xyf z>ZG!>McFoocEQ_uQ9_1y-FEoyz(WPJ;=|;Zb8zqPN^O zJ4ji8{n68H`J2Vb-A<%j3?Mv2KNq|cXRZH492sW2yISMjgS9yi8h?hNaG&7^fIk}ZAqbCP}58i~rp z7{*A$h3wxzyNcS4j5_Ug1dz)(mnT}GdyeVD$8V&>=@MP63w!=lkTwM}!3#JN7nC>) zbY1-LBv*}Bf`nJRo<6y1u{u!|S>w0z3>^I)w_cg>YD2I^3Dx!Oqz_!n zmTk$ODnfAgM3B%%;YNP5bpi4`@%!T{bB5ni_?AfVRmRnUcNg4_)P5vd^OUXRo_kz> zHp9J>xBM`bt$mw^d*dmxbkTQX^N)@WYeACqoId$cwkOiT-gc&9P`*B~$~-&K(`o}x z#lp}lE74+{SNH`Mfzsg{k@o*3xLZLVXIblhQs5MnU0S7Nt{Oq^l?S}cJAW5;`$}j5 zwoBtG*@aiaajI#n;gP;$%7#m{)IWPf@X7T-s6ow=?OA^W8dH}n<=Zwj-+7b_U2 zuDmxTf23e@srQanoNuG)pLE6#Xw*m?$SZ3g#=kS~23YO)2lc&<5>Is6*sXYC_YBSY z`+iTxIx$xFO^|hG?@}EQJVq*c;luOu9lH+|&n17o7M(Sc+shT=f<4(_C#Agc1?eEN zz8L;6^%WX?EP7Xrl}S53Gj5ng<=f}{Q45pC5o-xiyNw4%s!P=8+`upA*LKF_q}+q` zx7jKN_QlJc;qk@$*K;-8Qz`AvCYx7Qm?1c&r*^aY-_p+Jp*ZY5fFD}vQ%C%?s`wmu zJ5I63OZ`xL(53amw)P~X@a)=l#uMbU?BnWct6xJBA||)VGM(h-SNo4HWKaD*-lhQQy>}U|42>(8 zOJ%wgcnQuPL@WDt0DhMk<$G9s-=sCK$mFDif5nr`Mp#ZVT_TBj`oiSdBt?4p+Sv!y zsWB1@vgaN&0nA1b2BQ|AMYc-cO2*KAWfdT2uKFs_^%l`IB01v-H_;JlQ;w9f>ykAp z9xi*hl*(`v;s<*3%)dzgv(efOKve7tmwHa3dJl1;8XcXQ_W+s#9+Ppt;X#=_Akm6|PH{Pef*wy$tM1Flb~+d&e+X5GJ>Dy0+!vRjG4R=RV5EL2q{Bt^cRF z!~q7Uc8SM&Q_kFX7QJxx;o5NpDU$7$)LY@=XHL9%VO+S`I&$}5WuDffHltVJzd z z%SG3`Ri;)vH;rJ7`~DX=o@86LHuC-wUq%P`X+&Sz&ZH3@osJIubZabMUal`}a%HY6 zfwqjxmet-qp6v?MW^C0x?o8H~;}bM+<=LJj_n__lk_#Qc!!etX@tdU1X<4je3gW6d7kHPx=2@8hghou_JX{&`r_?ZXUU?vYa_HS&gZGTkt@&-6jt z*?wVOP25Zir=LI#nI$^qN-1gGh-G?kPW8<*veF^Mq>u3eJUoDJ2mKjlk9H-7@LlQt zx^w5II7fic)wHr5>Mg%IOT`J=Id5J^Sp9YAgIPxU8031#a$;Mad0*Y_Z78)f{v9@SOWY zw|gAJ_*{;%6%?R%wo5--rK4`o7_|(hrr$iwmu=Q=VBq#M?|gNgL@q#NUFTM7MB#4E z=gXfSe&zXD-c2#H@19MjvXZs;?R7v|U&;r*J&Fk{Jzf*Th3A?WDj#t#>O;yxnV8|J zOPtdUjOW1Tw~`JE?l3!gO|^HJz(6&!%Y7G%X}?;ah-NQ87{Bj>;Qh5oZRKa@Zf7%| ztW}8*mwFM+O}0OJ%-h7a?xx^gcwhB;#pzs^3%%oYwQl8LR9o4Ka^bYOIM zYmMO#DTEV7r7of@vZjdsNcW3xKA2lSCJ`06<;IX86@#_Wk~h3@Qvge z9Us=q%*{A773AVFx-Xl>ozfOcJUZ5q)!~nK@P1u=whYzs5*`?pZsRUT+(IcOx>!EB zZSk&~jdP!1fqQhkE6#7w1<=Jl@i~>vN--y}auASAte2|gnhz*whHqy$^>IKT-H(x1 zSUCZ;zdv+;YiD~$SiLF;%CrV$)EZC-v11=sZfJfq3SQ`QbZ2-D|HX3Ay&;CApUZrx zAAfpoQUCczvbf@x*_q<}yCy#Z3OkEXgcDrNu|ut2zylOwjv=58KexFObbg3knOQrB zr7m?KfIats3m-DLACc@;VJ7F)30Gwx=1Es2{=0I3kT>$alGaUI5&R(6_9G!U{ z&sz=odNv9eGdAZ z@hV+lK56j(dUo!j2_wkcX$PIP=)1)ZeAJdi;SU`TUnO>sTxq z@m$E5)XYt>EJ;KQ$ z;BUgm$y8E#MP>t0Go>xSu9PKj&kDyfcqDG^ahFbx!@42LeDP&&RMc5mp6gd<`fSMq zHo^xvzy|m7XjHzt3pmR#P~LSEx`C7)9F>lvWvUV#8d#(^0EMi2sLc*Jx+o0`4W~OF zx;*;D_l&mUL)7!K?tyB&*2UAfD?h1p`IdE6sU4D7g&6WeLmF=bq-m}TRVr78Xm7JV zvSiigF?__VBHw(Ew4+0+nzi4Wok`DFmZ7ZrdVo65aMKM&# zSB5|~2GK9-4-+6>`HwDq!C(qQIU}z!ld0Fh-V|EPN~Uj2s$WHfvxF~)>(z+~kAF~7 zT{Nn#+EFi@I5J7l2mDHnFY!jU_lcLGW7P!`fr~*I;t*N$78Wq?L>&1p~wY{pGtknoG5L2b;2ZV%g?o7UyH6GzumJ1cX zB*>9Q{l-=mU!U7F{{M9Km0@u-O}oqD?gV#t5AFnaTio5<0*eNB*Wm6!f(D1+?h6EW z2@rxGp6B|`dEfK(kC~dDs=Kf0p6=?Yo~j-+#<(_K-S_5Pn2{r#i?m4^R-N+>wTe0_ zfeoJ$rr6OW4Zx%0|I7F7^Nb01zlV+nj9Y&pP49915|#BSM@y>U_Sn1tXzQ)0 zZ}kTZaNZ|pOmTRb+TG0YYL}-F*SImdgdf-?z)o$ z;CTwy3Q6kjf}$}5>7RyueG2SGe&Oo5+&w275=N9*5)Yud{*bJ<`%cZp*4`PFGdMam zh-wQDWzZOv>s6vhfJzVS#ka z+NiTRz3~$Ia&GKeSUBD@{pvnRa9Q8%bPGxw3#SJDEM9^wQs>85R%Oi}y0c%0Uu=~g zhBzjc`Ba+7qoh;0lm)d0`UkL8o0~tHu$D7~%SmA30$W8yC%6db)MF2kW{#&!SZ@J9 zHo7Ul5ax68$Rfo^1B;OeMSwvz1t@HoM>)A*G@3bKzG5^vS6_eeqA!Ub+?txkK8k!_ z$Qtcti-v2}Aq3+#P$M`v2oUI0)>c@bku1Pj|0`w^0%Ub8_9cef*OZ_{3VT5(a*Kqh z@=}+Znzgk`2bsT4&SH7i3#MK}V|54ZgPW!5*FXUnH&ccT(#?)h{D{1 z-9p`vfzOGH%1%gqN?-a%Ddf?<6j0Dq_z*Y1N+y4w{l?rQvDVk;*YT0d$tr(y*vnc* zQt=nC4mAnzMKZPZ!PcL!vUdgz3@N|`!OY5an9}W*`l68` zHpR)Q3G8E=so{NKXR-CC`ihp7`?WcEW>sof?QpjKzO!wiTd<)FJ^cJU%364V6_FO` z+$W#7wlTJzKUzc{UxWY^LauPrY)LTJ&WC_lUb5paEZWI~UjFOlZ<7MAOv%Pq)8}|6 z7k`ly_JIdm@D?2q8zUw2j#Hv6u&%|{Jnk;P#ozvBe8NhJEh^-WE|bB(XnUKT^QQ=0 zdqIXo47?funtm!o*5&d*6P@~EWk}iiOf>!nZKU8Iu9VxyI8yy}T7-g!M5G6l*wn96}nxAh?Sa5f< zA>4l;{Q|Xf4m9yXuEP~&vy$noz`0K$NI+?iwQALrttge)fLP>C_Q z)ZTXspXuj5Tod22#=@N>0^zE-3j|HHaz76r*%gA_C?$>?;!zAT`R7ttA7)&t+F?Rd zoQV&S0sGQu;~Fjjfr-MK4i*{#4gB^!jAJ_>EP%1aGO;m&q8sf9#~_dZ5+puTUu(XA(<*^l4I(#Xg)Z zrDE)?OgQ+c6Jd_>1AA$Es zDvf(v`LyNZrR)zn132GN_d;{_XRGGgN8qx)&&oS=X3^w={^l7Oqf9PjmBb7r+=+m> zEaAOo(go;M$6`hHRB8Br10MVu$UHnFKWCeiBQ1IBU*8rE8h^Pr;g&sCElutG?sp&p zHwv#ahU;+Q0c(bhdrncBJ(3uLaJw&CN0WBzsE2`i(=i|7azHBsYGrCaa1u$MjOX?W z6KbXL%!D5p{W|6}P=O48;pgkuiERe;Oi}|R#$|oi2Q}elBgld z#^|hQmQoQJtagJ&XxE_d!yc(r9QVyj?n~nnb*Z9DQi|7K465IZmTBtL8hxG5Dt!;GX~nSvuiu*X&)QCN5R%$t6<@Ep zdHr#~L0}^4RXobkgz5=w(>dsSoB8o3n)(wfaWl&Hx_ErZ`1ztlkRyCMOx>m)Lc=-v zC-1_YpY8H=y|9Mv{_B`7q01HEC(e2`D%VZ9Le6$Ud?S+Sh?L#0+e4{WS`JpxPlL6Z z4bAAkSW{)(j2O)d`P$&%jmyG7oZCf4OHC1ZKP`J_^un!o*kfYpPY}1M({9#als=nA zT|+1TE$TMV`}`}3;PbDnG;*03HU*aEzMoYjRJHynx_?cubmi6hqNs;Vz`NAX4W{1w zYOu4Jl)QQCv?>|`sd#wU_^L3Zpj+|b5tv-^{^(q#O1`sb;h#fCRG2J2Y;KUZx5N1X zg-biWOGCGQGt9Rn!rAD!0+O&&No8QX42ea|ch!RxN;c~m?SFr7cSl%o?HqeD$ zi2F+uOpHLyoWM!!6b7m}_^pwOMhxvIMeMKn>e}MUx(ct&vc?X|Bur37|6Qa|(Ah?C zeALN8ok65q>fe*Dydb-wYvSG%4m^ZuIR9QnC@Z@@F#u(tr#K#5(%?M{gfc1bhr`ISP1{`g9XCX$Ep^))N1&oXG=R~?KHpa^K>eyTOa z3WqLGG=t3PCsjyj(${I!d_+ejrj{nW1s_gnu!;pA5c&Ae$_ii zH+ThZief#;b{>X&5ck2e{MNl^1Ao^ky8A_ej5>#=$Q7U<4iZKk>R;O4@(F7w; zya5x>nWdR;c>q6_FUkByn)*&Z+lFm&6toF}aT8O3*nlWeFYsg#{ z<%<>a2>gTkh~nOFULR}e?VOaDR6tfm0xe3__^aKZWr^+VQr=o2M%$C%5HFB691;q* zr7i(|mwZ38B^*5$GVGtMDl6)lq$K99Fo}8+NpQ=))^U0rB@#MbdGF4GSs`;hB=&2W zO|`YhHg>ynaJG=}frgCipP(co9yS9k)Vvf)^2+f>SrN)lC>>oC&j9YjXmb7nWEe0hlMg+Q8`V(Ul(RDJTyWS6`I??4~U=#pA?3YHv} z;6+4&mdeQ8ViEB`fDRD@(;l*OV;KA}HJH_9ajG}SKqQ(8e}XU1F4q2oE(ag0L!;E1 zki%Nf3`&f4b^tdIb~JYLTHSgrSQnD`q^GlOl;Ddk zq%r?w=i+wQk8tyRpD2l1))FIX)e$AfsJMJIiDLb+FbY(iWHV@iTAR#oW~0%`gx){SOu+V-Tnf77?_Cj_TBD6m$swrVeW*&@)Z{WzLoD41E-iYUy{*NM_% zc|rrq18poV)$@eywurnQ87iOrj+#*o7EKX0rW!WH^M7<3C$M2-f*MorMni{495-+V zaIct6f3=kwiJGS|@m!lI10N6Dai=vybbcfS);_UV{0Ki^*3$U3%I$d0z6$o&r*IF7 z5~4H#6}km!9UGzGT&!1x4)xo0`(V7rTr8TDp^3ZHcsFUOnVJNrmsp5PODjoiD~Cm@ zBgG`{Y}=V16$2iFLXgIbW_qY48S5k(whcGG`o{MfV!)Vgm+6z(NKQc4^QpQZm|;z$ z!pK#Zc_F0hc->4S%P9zbZwI^jn10ERVa-y#=j*iSPn;u*k5=)%N$Pw6@pk5uAdH(2 z6ceP!uRg1w^Rda}Q}mzmtZ~UdI42X-q>s<9TP+D($am^=yL@DWOzPwdhh#F;pOKoP zAG`{8{OJ`FWF|5MrK%}qlMTmNvu$`UI}39ab$7LZG-k69C^AtjTfugMLMA4b+wIhu zJ@Nt8nzE>3D-tS=!=vyBWEcu<_u2{iPXiN^|DhB8Eks0A~PzXOb zuv7@d$ZxDSx;T%_b(2uX67yMD1)x~|t}uYy0pG=~gY_QSSEx-58kDLs^m(I+*XWLW zrl^O)k-I9%>PkQ<5~5fPp+m*oJq(N#Z4xV2tRF zv=kAEG>v0q2|d(+hGzd&_*cWJYDE0gUL4Pzm_Kf|*Ws5I|1j>^Tw6-hkXk6EseJor zpw-^eR0887&VuKZ!zm=)?jd5Q zIiYEVNPt!FPI;o~EgA~+M0blZ7s>fJ)!x0+ZTE8qMC?;jUFO_UQ=5Nbxk4q^mq?-7 zObpP+TH60o@uf$pXVP6L^dO|6QDQu0Ww@>x(3aOBHNROoflV|V;l*nTQ-Xbt^&RM{ zi#nN~^4qQ*K}3R~_T0yaj^x?lLD~J)l0R@2lm!M(EQCPeQmsYk)C!qKW_*p{G z6jmcT{`&rr-OM?56WWRPVeDS-aF2K0!BL8#0=B?p)Kgsy@sXJD+MPow^yeqsVjs|= z0%OwIhCD)r&3>oXXcpIxL!je_;SC-<75>SA8VPq)~yv6B|Dx~DrH#8 z^=VggB@7n(I~}R&`{aX}-X@noqSgfO8QiEWOnT9;!BUYP{Tqby-WkKIm4#!P7I!f7 z6%`UznR)!dMZTQB)zPHk@-su z&59_*54BSKuN~DDyBk_!%%-lu7R}5Ym2AHa_dT3s7Jips-kkmWwXGQ*MZ8nXj;Te< z%W_OWa7eXSCIr=O>D&KQHE77li#cjn^r*O|7v9nm``LQ04-ToG z{aP#wYHUJ+V;Tj+#&n!Wze=W-M6!iJ+cur}GC`W)#9wVUN6fFOupCUvJY$rv$82Ii zo}uim5No?@nFN<652*5Tioh=UEn0<{OlKqYK}&j3gUv$`Z8cm{;}xEb{o3O`6FPtM zfB?-%d+nkQN%3r0Jnk2BOGmwvLAk0QyP0%4tO;Whr+G5(X3M81K$39)Z`+S(y|bnl z0lV487bh8?5G1l8VO228mFUxmUo$dY`7ncDtPvE7$SGW6GJx$6#ip-vToWZnR z=gtNA&mRDQw>Ls)fT{vC3=RMefbbsvmja+~cNrB03ji!*{kuHE|IhMBE@;brhZiI8 z{m%yYgs*E6E6L9aRzW!i2DH>EVMcZ5-^^irrpTAQlE+`}41WS0DA0~3Ezs(_zj~EA z|48G0z6~%0IoDLV_YkbEh_?>$5_~<(*&ls9J>835(}ui{|9V%bM5|;qt)g+@7t6m> z)y{X(jl;k&C1G%rj*l!`puqRXd42xJ>BU#1jZSF>*No8NlDK@h{x#X5$gie?9ZHx(;H7q4?TRZ`r|zD{+Qmgy@I-7UX4+sueQ} zr2nWHkyN{@EhlyArFxzOtFO;ldRDV`CmUidJROISxh4Y^E~Mk ziEQJWLEhYhW$*-l6ABjB1z~zFMs9yQ3LdHX@#JqOrq7eai_9mmW4%ztmf+47*y| zVfq5kXJ-0B_~Hpd4lG;k`M5k26?zGi{?CM_Y{O8cuHbXpF?9ameLci4StIO4)Km!2 zrKUJwlWBCbuVxZdH(lnR<@8qgZh|P97As391lmd-%-k5*MmfH4o5E>jThAeTKX_`& zr%@UWEH@SLAZi?hYVo*Fpm1`8Ze&kte0xyN{;-P}%&&uu={JZT(n~dZWAcmP93K3` zJs7CTDvsj|MQIvqOPm~ZQ7R+Pd&_|xL#9s+UggrZ9Xjw@SL_qi#YYJ#&?^)EU~ycKQEFcm9R^>)trSM5nls+-D>%~My202~!q z%>L!N-kmZ4;pO55$;e05Uu&@{sbopFU?@Wxj8458&@D1f3cd_fRKfORnpd?!=a8>N zV3~f#H#v{;xy6M)Mo{8^55GLkba=GW;BPw;xJc-bPF@@d0fn>XGqc2T>npHLv5FDY zRseuX)#s5#4l7UZ$MP)LM>?+uJ@Zf?7mtgj$PCkU%N&#Q58Wv8DS%o_c&qi#v^rf1V$lRbG}ba0hi6@&ou-z`I6 z1(#F}8CQ6eoTSKj*{M$!H>M|~y#!wfsp+jbq7YvH2(Zt+>di1=m*ZT_{LPAYEq9oL zbM?5a#gB7b|KvC~a`k{1XecUlU;IVFv(qdnI`&&CL4k6P8B6A@whpUL4Pzhq3W%K` zpRdDlX`!RV_%lt=7U?Uaz{f}B7ZXXrPusx>*=V78sTq40JqCqlcq!8OPh4z2m9m+i zeNWw3%!Vi$~Ft$H)`{8!CpI0B*Yzv1k|L&Mg7v~%uH zAwMDk>n9M&B!_Q($b2KeeTv=q;BSSO4lm8iHYB)u=ESoFqbtZ;5JQ0&0|Eaq&>@AY2fn=A{Ma%O zCM^fQj4W0=Z*2v<-a$s#zKV9WKW?FK)xF-0gNe-A%yPpDIx9Z;lU(OTi$u?ge&)d++dcco= z9}gnP0{vc&9kx$0zHa?^d_1sod)i&B-kMh4Fz9~td7WN79T(j=Cd2Beoq7Co=C5N= z1HPLSMa(18)CJeid}-xvZfOs$okVqD`9h9kF!LOu%HbXzVR$u-Bray7pI@+Y_>oyb4K&>Fx5U`V0XC=w*m6{2Djz*T!qC3RdtjIn zTZA}(aN%p47~03bBIaYwtAJ5`ayoKrveV|dSb*?Q@^;Ij?Kuk{9r@uJ9}&<`%sxR( zS!}A+K5>era)x3_IY%d$I5^kL@FK3(Y3Rt%YeVQv!T=^Lb4lhNoLOtJp zQ3YTp>-d3(ss~nlt!0R{Ki420>uE;fV)jj5ACo*w9#{%_z=aUcJzDL= znJ+WHN7hdE6FfawE>C(vn~QTd2`JzG;N;?s#&V$?TqE-3X5ck+ z5sRImnG#fL1=6`soM@1hG|K?xHN&U(E$^&KqLtakd#@ z&ONSjCDizqRx%W?kz+ivPNec;!5t%W$$m``Un{?L=&L1w%*i{$j$C=bSi}Z%138ar zNxTt9QAUYJVW>=zEZ{8AEJAiu84?K+A9@S5gblNH5Uk!aOHir72}*ck>0;VqOJbV- zdfJ^>s|5?tiM(buq(EJuE|e~`8aPXIdvN%d(6p^pbayxf3tI9272p*!yWD;4JzNnd zuqNDHoe~e;fS$ciE4>X^rO^NE8Wn454O3!zz9FMz&SmmcLDR;5zae8t+pvMg0&*D( zQINRba0DwMvU~x}dLO{7f42~~lvp|&f6i>x>kuHj5?QkT=1GR!EIvg!n*h#5TC)dnaV2HK3Z}k@pog~*v7PPJIhjYL$h6Naz01a|3a(8m%$57#i z_gZ*wjS#Ajq!d%Vzr-OSuLa%*VtV94wYfVJu3)&Z!(?PoKBZ(9)H^~jbI@6k!{v$V z4BG09RglKFH6A{VmH&Io0bZ!)>5Zjl>`qM6p6P&o5vU7TMOo1LHpK9IWL4~wu0qT9 z6?dGB(^|2gvd&EpqB2{#n3dRp7#{R_l`r1(pR%^auLOzwiFgPJ2<3cFIZ(gA58J@> z^3fRUiPYd`F%QqIfJSI*fBl;o61T%iKzU%hy^B@DHrT_O#f+SSgfpcU!7?#N-~a1 zMsuiYjojdgpo#bLD8GWaFHaN+SEGD&2#`T}J3{}y7O+i#BH^MqNmR6+LTcpd- zAtxWrn(Tn!eN&`GBIsA$q3*$Nt)&xPS6*Yc5+_`#6GvhAgBG%>yO>ra$W~AIm9u9Z z1YNtBM%iAe6*r5_)FE^8i8D9WNZOeN&XcFnt21wn)e^Kh$69rvB7MLS?qBJYb*ql6){~m6#jF@r6YLP=5PTL~vt8)+ z9)Vs?o>JZsYjt3X5s&-6z10JH3U8EjR2b~X@08qB^&P9}dSP;XX$UvcU+y$h0B%QQ zTHxE08ESUpQCTw4mHOoS=F1Vc_N_b)tgDHiFAZ3o^bpz>^A0?@_8<(`ndI+HnslUphS$MfW5&&FO3(;=hZr@oMPW1%&LA zFkhPRdxVo>g3!W?-Ax_<;~lasX5dF28FUFY9@qH=^Tlg_yr2ClhU9wU$8V@}(iP(7 zfm$pS5coexW}LI=gk7Hk*UTjzS%Nmd)9PrwR*i%f)J95DY_lW%2 zCm5OSY8w`nwqao0E^EBXz@L!ZC(myi=6!6CmHUZZjjUNVLrZ<}V<yMET z?0aI`j`1_xL5E^&XlJUt84~k^a76DfRwE2Dctk_G@l>8@1VevT_&vA3Y_KyF)+>;s zDWHfg3Vd=?CQ;oT1;%QWKYj;CD-2iq5%uR-3_{XzD}@OkrJ2+RNJL8;Fc!2JrWk9} z$M{TF`vKw$*`pi|%mo94QY_82y7YB?*glnNF}wKY3*b*8_Mm4Rm5D@U1Wgr;SgC@@z^9OFf}^!imrrwz3<_sM{jVWIw_DfK@ZNy|T~f z@qvcf>1`_>EEf70bRaNZDuPoo;0jQ^Fmiqf>sUb)SSv$PX%(^1k;L< z1KL8_(3p|~Rjj$>Cb7J5S9Hh&O)_{h>6Ij&j&s*S5DzX94-_Dq<#`;+xxB@e55(+VWXN%oTY$NUOWIMCYk!JmB`+n z-Okodp#zJ-)fNJoU5U?=Zb- zYkUP!eHB?}_I7yB+Q6`Lx`~$rv3RkPlm<1Zc<{pY0mZ?q47m)sJ-MH7Uk{;6{wdP6 zX0Xrc5FFUDh7kkkXRij~7Sh^o1fC+*Fg6Uz9Z|*q-4(_s!no$rkQ}DJ3ww(GTiBe| zZ|ltUsgf>tLIl{??&faHKQ~ymsm8bWGv5^FcLyRK^@{| z5Y=Eu*gv>FQJ*QcviP8qrl$DwNc`(1I(S1pzV4_x`1#kcemD|`ke`bi@}VSy>n00V z9`4CAmz6XVU~dFFs>UmfzWu7In~5#87$c_T1}03xbU7LzNVFEFU+ny!hP>*zbKOaBIoo^*exK zAi0_{0i>bdg8uS0Ti>%5-(Nd|{l2f*3_5R}YjkP0UHMzmHx%@+r+d3HNfLm))dY5C&n$9Ew7(0kVoGiJnl zKUfa685ds^R@@7}uAdm7 zWZoIcfd^d)F|v=jX{^&@r8?$Qp>rK~c2aEeG^^E^TkWj;eyuaZ<1vB9%loE1VXP{L zG# zw|ilc7LE1hc7r~AF&gLu_)RbecRU~Ubs$q|dg;dGw{@`J78&AIn#%voVe->qL$@-(d?HNZJH9$DKoiqLWzff)n~wtPy4tMAhR|rR4eC-j zeAvMs9r5*KqXx_QR+8MRL*J5%|5ZT(_PSW%%qhHVwgThqDI+4B`@VI6?J4Z zQmnS@U8Xp9>DvjmV>nPy%xsS*0tr04| z*=4B?O7N~2GGeHdPPpPh{vla=rU*(fp~8?*mdLZvxxou632yEa4)dw@usLX?%Oi+% zU@QrZonP^=#JO3UTx9N}-{+IFI(z`P3N z1eCkWJNyhqNmB3t9q$ye!Rg2Dfw&YZR^ro4DrGpQ-!a|dU9#@+bvCr&nYc}I6KR5F z`z%;?>!`NEt7Pw1+k`p{IG`V#6tuSci3xcqF1@9yv%aZ{3ByjI`a9>2HZ#Grr&BZ& zD>9H*DiaZ0A}}toF{U7TkSnl6>uSAC>@;%nfeN-V4M{7MqL9Ty8L}fgolbl_gO&6+ z%d*^)MmR4YF2RY(Fi%`bm1o~j;mE=Z`$q>raP5n$bTHm8o5ZcSNc3@3GAI=S1mbviGD)dc4qn)4l|RPJoi^6b@}2 zWf*L6QU=TsD^XcQ8r&cJkq^*&E>u_i4AZ!vW$YAVPQ=zvC(4$My6eVfpXxX31d3R} zf5BICb>n1i&FMRWLk=}Rj!kO;GR{re(}jYb==Myk;M!TC8m=D~369hzZ`JowwX7~4 zDfz_RVHudSwIR;rvUQzTy)7 z?>$4`?WX^ezNaL;3PAOxOuW(&|7Sxr0N{P8@xRhBX^I#bK??mFBT&NlUsT&SHXw$@ zzhwOzF7f}1>p=tn5d4=Q08khFFVo!{JFqk|jSfl_sGaanPFesIJJ2WfUvdzN4fwO+ zA2I_83JRC_KW^Ip8||^}UoKUscj4h5|I!)%Nc_h|3;=ld6#K8#G5pR&m{AIZ!XW<7 zO6mXR>fHJliwgLT^^av<1quN02Lb??|Ahnq`0ZzC0-=O~fTN5QAQUC>zlLTU06@?i W0KoYFIB`!iX5TsBU;*zyfd2#4C^1t2 diff --git a/Orange/distance/tests/test_distance.py b/Orange/distance/tests/test_distance.py index c38ece49ed1..0eb0fd014d1 100644 --- a/Orange/distance/tests/test_distance.py +++ b/Orange/distance/tests/test_distance.py @@ -146,14 +146,14 @@ def test_euclidean_disc(self): data = self.disc_data model = distance.Euclidean().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1/3, 2/3, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 5/9, 1 - 3/9, 1 - 5/9]) + + dist = model(data) assert_almost_equal(dist, np.sqrt(np.array([[0, 2, 3], [2, 0, 2], @@ -161,15 +161,15 @@ def test_euclidean_disc(self): data.X[1, 0] = np.nan model = distance.Euclidean().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1/2, 1/2, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1] ]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 2/4, 1 - 3/9, 1 - 5/9]) + + dist = model(data) assert_almost_equal(dist, np.sqrt(np.array([[0, 2.5, 3], [2.5, 0, 1.5], @@ -177,14 +177,14 @@ def test_euclidean_disc(self): data.X[0, 0] = np.nan model = distance.Euclidean().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1, 0, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 1, 1 - 3/9, 1 - 5/9]) + + dist = model(data) assert_almost_equal(dist, np.sqrt(np.array([[0, 2, 2], [2, 0, 1], @@ -193,14 +193,15 @@ def test_euclidean_disc(self): data = self.disc_data4 data.X[:2, 0] = np.nan model = distance.Euclidean().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + + assert_almost_equal(model.dist_missing_disc, [[1/2, 1/2, 1, 1], [3/4, 2/4, 1, 3/4], [3/4, 1/4, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 2/4, 1 - 6/16, 1 - 10/16]) + + dist = model(data) assert_almost_equal(dist, np.sqrt(np.array([[0, 2.5, 2.5, 2.5], [2.5, 0, 0.5, 1.5], @@ -243,11 +244,10 @@ def test_euclidean_cont_normalized(self): data = self.cont_data model = distance.Euclidean(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["means"], [2, 2.75, 1.5]) - assert_almost_equal(params["vars"], [9, 2.1875, 1.25]) - assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) - assert_almost_equal(params["dist_missing2"], [1, 1, 1]) + assert_almost_equal(model.means, [2, 2.75, 1.5]) + assert_almost_equal(model.vars, [9, 2.1875, 1.25]) + assert_almost_equal(model.dist_missing2_cont, [1, 1, 1]) + return dist = model(data) assert_almost_equal( dist, @@ -349,18 +349,16 @@ def test_euclidean_mixed(self): data = self.mixed_data model = distance.Euclidean(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["means"], [1/3, 3, 1, 0, 0, 0]) - assert_almost_equal(params["vars"], [8/9, 8/3, 2/3, -1, -1, -1]) - assert_almost_equal(params["dist_missing"], - [[0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [1/3, 2/3, 1, 1], + + assert_almost_equal(model.means, [1/3, 3, 1]) + assert_almost_equal(model.vars, [8/9, 8/3, 2/3]) + assert_almost_equal(model.dist_missing_disc, + [[1/3, 2/3, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], - [1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9]) + assert_almost_equal(model.dist_missing2_cont, [1, 1, 1]) + assert_almost_equal(model.dist_missing2_disc, + [1 - 5/9, 1 - 3/9, 1 - 5/9]) dist = model(data) assert_almost_equal( dist, @@ -426,14 +424,13 @@ def test_manhattan_disc(self): data = self.disc_data model = distance.Manhattan().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1/3, 2/3, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 5/9, 1 - 3/9, 1 - 5/9]) + dist = model(data) assert_almost_equal(dist, [[0, 2, 3], [2, 0, 2], @@ -441,14 +438,14 @@ def test_manhattan_disc(self): data.X[1, 0] = np.nan model = distance.Manhattan().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1/2, 1/2, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1 ]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 2/4, 1 - 3/9, 1 - 5/9]) + + dist = model(data) assert_almost_equal(dist, [[0, 2.5, 3], [2.5, 0, 1.5], @@ -456,14 +453,14 @@ def test_manhattan_disc(self): data.X[0, 0] = np.nan model = distance.Manhattan().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1, 0, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 1, 1 - 3/9, 1 - 5/9]) + + dist = model(data) assert_almost_equal(dist, [[0, 2, 2], [2, 0, 1], @@ -472,14 +469,14 @@ def test_manhattan_disc(self): data = self.disc_data4 data.X[:2, 0] = np.nan model = distance.Manhattan().fit(data) - dist = model(data) - params = model.fit_params - assert_almost_equal(params["dist_missing"], + assert_almost_equal(model.dist_missing_disc, [[1/2, 1/2, 1, 1], [3/4, 2/4, 1, 3/4], [3/4, 1/4, 1, 1]]) - assert_almost_equal(params["dist_missing2"], + assert_almost_equal(model.dist_missing2_disc, [1 - 2/4, 1 - 6/16, 1 - 10/16]) + + dist = model(data) assert_almost_equal(dist, [[0, 2.5, 2.5, 2.5], [2.5, 0, 0.5, 1.5], @@ -521,11 +518,10 @@ def test_manhattan_cont_normalized(self): data = self.cont_data model = distance.Manhattan(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["medians"], [1.5, 4.5, 1.5]) - assert_almost_equal(params["mads"], [1.5, 2, 1]) - assert_almost_equal(params["dist_missing"], np.zeros((3, 0))) - assert_almost_equal(params["dist_missing2"], np.ones(3)) + assert_almost_equal(model.medians, [1.5, 4.5, 1.5]) + assert_almost_equal(model.mads, [1.5, 2, 1]) + assert_almost_equal(model.dist_missing2_cont, np.ones(3)) + dist = model(data) assert_almost_equal( dist, @@ -544,9 +540,9 @@ def test_manhattan_cont_normalized(self): data.X[1, 0] = np.nan model = distance.Manhattan(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["medians"], [2, 4.5, 1.5]) - assert_almost_equal(params["mads"], [1, 2, 1]) + assert_almost_equal(model.medians, [2, 4.5, 1.5]) + assert_almost_equal(model.mads, [1, 2, 1]) + dist = model(data) assert_almost_equal( dist, @@ -557,9 +553,9 @@ def test_manhattan_cont_normalized(self): data.X[0, 0] = np.nan model = distance.Manhattan(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["medians"], [4.5, 4.5, 1.5]) - assert_almost_equal(params["mads"], [2.5, 2, 1]) + assert_almost_equal(model.medians, [4.5, 4.5, 1.5]) + assert_almost_equal(model.mads, [2.5, 2, 1]) + dist = model(data) assert_almost_equal( dist, @@ -629,18 +625,15 @@ def test_manhattan_mixed(self): data.X[2, 0] = 2 # prevent mads[0] = 0 model = distance.Manhattan(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["medians"], [1, 3, 1, 0, 0, 0]) - assert_almost_equal(params["mads"], [1, 2, 1, -1, -1, -1]) - assert_almost_equal(params["dist_missing"], - [[0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [1/3, 2/3, 1, 1], + assert_almost_equal(model.medians, [1, 3, 1]) + assert_almost_equal(model.mads, [1, 2, 1]) + assert_almost_equal(model.dist_missing_disc, + [[1/3, 2/3, 1, 1], [2/3, 2/3, 1, 2/3], [2/3, 1/3, 1, 1]]) - assert_almost_equal(params["dist_missing2"], - [1, 1, 1, 1 - 5/9, 1 - 3/9, 1 - 5/9]) + assert_almost_equal(model.dist_missing2_disc, + [1 - 5/9, 1 - 3/9, 1 - 5/9]) + dist = model(data) assert_almost_equal( dist, @@ -690,27 +683,22 @@ def test_cosine_disc(self): [1, 3, 0]], dtype=float) model = distance.Cosine().fit(data) + assert_almost_equal(model.means, [2 / 3, 2 / 3, 1 / 3]) + dist = model(data) - params = model.fit_params - assert_almost_equal(params["means"], [2 / 3, 2 / 3, 1 / 3]) - assert_almost_equal(params["vars"], [-1, -1, -1]) - assert_almost_equal(params["dist_missing2"], [2 / 3, 2/ 3, 1 / 3]) assert_almost_equal(dist, 1 - np.array([[1, 0, 1 / sqrt(2)], [0, 1, 0.5], [1 / sqrt(2), 0.5, 1]])) data.X[1, 1] = np.nan model = distance.Cosine().fit(data) + assert_almost_equal(model.means, [2 / 3, 1 / 2, 1 / 3]) dist = model(data) - params = model.fit_params - assert_almost_equal(params["means"], [2 / 3, 1 / 2, 1 / 3]) - assert_almost_equal(params["vars"], [-1, -1, -1]) - assert_almost_equal(params["dist_missing2"], [2 / 3, 1 / 2, 1 / 3]) assert_almost_equal( dist, 1 - np.array([[1, 0, 1 / sqrt(2)], - [0, 1, 0.5 / sqrt(1.5) / sqrt(2)], - [1 / sqrt(2), 0.5 / sqrt(1.5) / sqrt(2), 1]])) + [0, 1, 0.5 / sqrt(1.25) / sqrt(2)], + [1 / sqrt(2), 0.5 / sqrt(1.25) / sqrt(2), 1]])) data.X = np.array([[1, 0, 0], [0, np.nan, 1], @@ -718,12 +706,11 @@ def test_cosine_disc(self): [1, 3, 1]]) model = distance.Cosine().fit(data) dist = model(data) - params = model.fit_params - assert_almost_equal(params["means"], [0.75, 0.5, 0.75]) - assert_almost_equal(dist, [[0, 1, 0.367544468, 0.422649731], - [1, 0, 0.225403331, 0.292893219], - [0.367544468, 0.225403331, 0, 0.087129071], - [0.422649731, 0.292893219, 0.087129071, 0]]) + assert_almost_equal(model.means, [0.75, 0.5, 0.75]) + assert_almost_equal(dist, [[0, 1, 0.333333333, 0.422649731], + [1, 0, 0.254644008, 0.225403331], + [0.333333333, 0.254644008, 0, 0.037749551], + [0.422649731, 0.225403331, 0.037749551, 0]]) def test_cosine_cont(self): assert_almost_equal = np.testing.assert_almost_equal @@ -742,19 +729,19 @@ def test_cosine_cont(self): dist = distance.Cosine(data, axis=1) assert_almost_equal( dist, - [[0, 0.257692511, 0.0741799, 0.35509797], - [0.257692511, 0, 0.287303355, 0.392507104], - [0.0741799, 0.287303355, 0, 0.12011731], - [0.355097978, 0.392507104, 0.12011731, 0]]) + [[0, 0.174971353, 0.0741799, 0.355097978], + [0.174971353, 0, 0.207881966, 0.324809395], + [0.0741799, 0.207881966, 0, 0.12011731], + [0.355097978, 0.324809395, 0.12011731, 0]]) data.X[0, 0] = np.nan dist = distance.Cosine(data, axis=1) assert_almost_equal( dist, - [[0, 0.288811225, 0.15707277, 0.175914357], - [0.288811225, 0, 0.265153077, 0.317499852], - [0.15707277, 0.265153077, 0, 0.12011731], - [0.175914357, 0.317499852, 0.12011731, 0]]) + [[0, 0.100977075, 0.035098719, 0.056666739], + [0.100977075, 0, 0.188497329, 0.246304671], + [0.035098719, 0.188497329, 0, 0.12011731], + [0.056666739, 0.246304671, 0.12011731, 0]]) def test_cosine_mixed(self): assert_almost_equal = np.testing.assert_almost_equal @@ -764,11 +751,7 @@ def test_cosine_mixed(self): [1, 1, 1, 1, 3, 0]], dtype=float) model = distance.Cosine(axis=1).fit(data) - params = model.fit_params - assert_almost_equal(params["means"], [1/3, 3, 1, 2/3, 2/3, 1/3]) - assert_almost_equal(params["vars"], [8/9, 8/3, 2/3, -1, -1, -1]) - assert_almost_equal(params["dist_missing2"], - [1/9, 9, 1, 2/3, 2/3, 1/3]) + assert_almost_equal(model.means, [1/3, 3, 1, 2/3, 2/3, 1/3]) dist = model(data) assert_almost_equal( dist, @@ -784,23 +767,22 @@ def test_two_tables(self): dist = distance.Cosine(self.cont_data, self.cont_data2) assert_almost_equal( dist, - [[0.2142857, 0.3051208], - [0.5463676, 0.4136473], - [0.0741799, 0.1917096], - [0.1514447, 0.2125992]]) + [[0.2142857, 0.1573352], + [0.4958158, 0.2097042], + [0.0741799, 0.0198039], + [0.1514447, 0.0451363]]) model = distance.Cosine().fit(self.cont_data) dist = model(self.cont_data, self.cont_data2) assert_almost_equal( dist, - [[0.2142857, 0.3051208], - [0.5463676, 0.4136473], - [0.0741799, 0.1917096], - [0.1514447, 0.2125992]]) + [[0.2142857, 0.1573352], + [0.4958158, 0.2097042], + [0.0741799, 0.0198039], + [0.1514447, 0.0451363]]) dist = model(self.cont_data2) - assert_almost_equal(dist, [[0, 0.251668523], [0.251668523, 0]]) - + assert_almost_equal(dist, [[0, 0.092514787], [0.092514787, 0]]) def test_cosine_cols(self): assert_almost_equal = np.testing.assert_almost_equal @@ -817,18 +799,18 @@ def test_cosine_cols(self): dist = distance.Cosine(data, axis=0, normalize=False) assert_almost_equal( dist, - [[0, 0.486447409, 0.11050082], - [0.486447409, 0, 0.195833554], - [0.11050082, 0.195833554, 0]]) + [[0, 0.47702364, 0.11050082], + [0.47702364, 0, 0.181076975], + [0.11050082, 0.181076975, 0]]) data.X[1, 0] = np.nan data.X[1, 2] = 2 dist = distance.Cosine(data, axis=0, normalize=False) assert_almost_equal( dist, - [[0, 0.32636693, 0.142507074], - [0.32636693, 0, 0.072573966], - [0.142507074, 0.072573966, 0]]) + [[0, 0.269703257, 0.087129071], + [0.269703257, 0, 0.055555556], + [0.087129071, 0.055555556, 0]]) class JaccardDistanceTest(unittest.TestCase, CommonFittedTests): @@ -847,7 +829,7 @@ def test_jaccard_rows(self): assert_almost_equal = np.testing.assert_almost_equal model = distance.Jaccard().fit(self.data) - assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) + assert_almost_equal(model.ps, [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[1, 2/3, 1/3, 0], @@ -858,7 +840,8 @@ def test_jaccard_rows(self): X = self.data.X X[1, 0] = X[2, 0] = X[3, 1] = np.nan model = distance.Jaccard().fit(self.data) - assert_almost_equal(model.fit_params["ps"], np.array([0.5, 2/3, 0.75])) + assert_almost_equal(model.ps, np.array([0.5, 2/3, 0.75])) + assert_almost_equal( model(self.data), 1 - np.array([[ 1, 2 / 2.5, 1 / 2.5, 2/3 / 3], @@ -869,7 +852,7 @@ def test_jaccard_rows(self): def test_jaccard_cols(self): assert_almost_equal = np.testing.assert_almost_equal model = distance.Jaccard(axis=0).fit(self.data) - assert_almost_equal(model.fit_params["ps"], [0.75, 0.5, 0.75]) + assert_almost_equal(model.ps, [0.75, 0.5, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[1, 1/4, 1/2], @@ -881,7 +864,7 @@ def test_jaccard_cols(self): [np.nan, 0, 1], [1, 1, 0]]) model = distance.Jaccard(axis=0).fit(self.data) - assert_almost_equal(model.fit_params["ps"], [0.5, 2/3, 0.75]) + assert_almost_equal(model.ps, [0.5, 2/3, 0.75]) assert_almost_equal( model(self.data), 1 - np.array([[1, 0.4, 0.25], From 8072f27f8b34d36b3e799b1f1a65ed89a33ea204 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 20 Jul 2017 15:37:01 +0200 Subject: [PATCH 21/27] distances: Lint --- Orange/distance/__init__.py | 12 +++++++++--- Orange/distance/tests/test_distance.py | 26 ++++++++++++-------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index ab8702e0b5d..6373ca85b24 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -60,10 +60,12 @@ def _orange_to_numpy(x): elif isinstance(x, np.ndarray): return np.atleast_2d(x) else: - return x # e.g. None + return x # e.g. None class Distance: + # Argument types in docstrings must be in a single line(?), hence + # pylint: disable=line-too-long """ Base class for construction of distances models (:obj:`DistanceModel`). @@ -101,6 +103,9 @@ class Distance: axis (int): axis over which the distances are computed, 1 (default) for rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers. Attributes: axis (int): @@ -392,6 +397,7 @@ def fit_rows(self, attributes, x, n_vals): curr_cont += 1 else: continuous[col] = False + # pylint: disable=not-callable return self.rows_model_type( attributes, impute, getattr(self, "normalize", False), continuous, discrete, @@ -764,8 +770,8 @@ def fit_rows(self, attributes, x, n_vals): """ ps = np.fromiter( - (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), - dtype=np.double, count=len(n_vals)) + (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), + dtype=np.double, count=len(n_vals)) return JaccardModel(attributes, self.axis, self.impute, ps) fit_cols = fit_rows diff --git a/Orange/distance/tests/test_distance.py b/Orange/distance/tests/test_distance.py index 0eb0fd014d1..7fdfb564756 100644 --- a/Orange/distance/tests/test_distance.py +++ b/Orange/distance/tests/test_distance.py @@ -1,7 +1,7 @@ import unittest +from math import sqrt import numpy as np -from math import sqrt from Orange.data import ContinuousVariable, DiscreteVariable, Domain, Table from Orange import distance @@ -206,8 +206,7 @@ def test_euclidean_disc(self): np.sqrt(np.array([[0, 2.5, 2.5, 2.5], [2.5, 0, 0.5, 1.5], [2.5, 0.5, 0, 2], - [2.5, 1.5, 2, 0], - ]))) + [2.5, 1.5, 2, 0]]))) def test_euclidean_cont(self): assert_almost_equal = np.testing.assert_almost_equal @@ -247,7 +246,7 @@ def test_euclidean_cont_normalized(self): assert_almost_equal(model.means, [2, 2.75, 1.5]) assert_almost_equal(model.vars, [9, 2.1875, 1.25]) assert_almost_equal(model.dist_missing2_cont, [1, 1, 1]) - return + dist = model(data) assert_almost_equal( dist, @@ -266,9 +265,8 @@ def test_euclidean_cont_normalized(self): data.X[1, 0] = np.nan model = distance.Euclidean(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["means"], [3, 2.75, 1.5]) - assert_almost_equal(params["vars"], [8, 2.1875, 1.25]) + assert_almost_equal(model.means, [3, 2.75, 1.5]) + assert_almost_equal(model.vars, [8, 2.1875, 1.25]) dist = model(data) assert_almost_equal( dist, @@ -279,9 +277,8 @@ def test_euclidean_cont_normalized(self): data.X[0, 0] = np.nan model = distance.Euclidean(axis=1, normalize=True).fit(data) - params = model.fit_params - assert_almost_equal(params["means"], [4, 2.75, 1.5]) - assert_almost_equal(params["vars"], [9, 2.1875, 1.25]) + assert_almost_equal(model.means, [4, 2.75, 1.5]) + assert_almost_equal(model.vars, [9, 2.1875, 1.25]) dist = model(data) assert_almost_equal( dist, @@ -441,7 +438,7 @@ def test_manhattan_disc(self): assert_almost_equal(model.dist_missing_disc, [[1/2, 1/2, 1, 1], [2/3, 2/3, 1, 2/3], - [2/3, 1/3, 1, 1 ]]) + [2/3, 1/3, 1, 1]]) assert_almost_equal(model.dist_missing2_disc, [1 - 2/4, 1 - 3/9, 1 - 5/9]) @@ -600,7 +597,7 @@ def test_manhattan_cols_normalized(self): assert_almost_equal( dist, [[0, 4.5833333, 2], - [4.5833333, 0, 4.25], + [4.5833333, 0, 4.25], [2, 4.25, 0]]) data.X[1, 1] = np.nan @@ -800,8 +797,8 @@ def test_cosine_cols(self): assert_almost_equal( dist, [[0, 0.47702364, 0.11050082], - [0.47702364, 0, 0.181076975], - [0.11050082, 0.181076975, 0]]) + [0.47702364, 0, 0.181076975], + [0.11050082, 0.181076975, 0]]) data.X[1, 0] = np.nan data.X[1, 2] = 2 @@ -842,6 +839,7 @@ def test_jaccard_rows(self): model = distance.Jaccard().fit(self.data) assert_almost_equal(model.ps, np.array([0.5, 2/3, 0.75])) + # pylint: disable=bad-whitespace assert_almost_equal( model(self.data), 1 - np.array([[ 1, 2 / 2.5, 1 / 2.5, 2/3 / 3], From 415be180b13e088d2efb47cb0dc7285c989ab293 Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 20 Jul 2017 17:07:24 +0200 Subject: [PATCH 22/27] distances: Compatibility with numpy 1.13 --- Orange/distance/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 6373ca85b24..265d5c6d35f 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -13,6 +13,8 @@ 'SpearmanRAbsolute', 'PearsonR', 'PearsonRAbsolute', 'Mahalanobis', 'MahalanobisDistance'] +# TODO: When we upgrade to numpy 1.13, change use argument copy=False in +# nan_to_num instead of assignment # TODO this *private* function is called from several widgets to prepare # data for calling the below classes. After we (mostly) stopped relying @@ -255,11 +257,6 @@ def compute_distances(self, x1, x2): call directly.""" pass - @staticmethod - def check_no_two_tables(x2): - if x2 is not None: - raise ValueError("columns of two tables cannot be compared") - class FittedDistanceModel(DistanceModel): """ @@ -504,7 +501,16 @@ def __init__(self, attributes, impute, normalize, means, vars): self.vars = vars def compute_distances(self, x1, x2=None): - self.check_no_two_tables(x2) + """ + Compute distances between columns of x1. + + The method + - extracts normalized continuous attributes and then uses `row_norms` + and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 + (the trick from sklearn); + - calls a function in Cython that adds the contributions of discrete + columns + """ if self.normalize: x1 = x1 - self.means x1 /= np.sqrt(2 * self.vars) @@ -620,7 +626,6 @@ def __init__(self, attributes, impute, normalize, medians, mads): self.mads = mads def compute_distances(self, x1, x2=None): - self.check_no_two_tables(x2) if self.normalize: x1 = x1 - self.medians x1 /= 2 @@ -691,7 +696,7 @@ def fit_rows(self, attributes, x, n_vals): discrete = n_vals > 0 x = self.discrete_to_indicators(x, discrete) means = util.nanmean(x, axis=0) - np.nan_to_num(means, copy=False) + means = np.nan_to_num(means) return self.CosineModel(attributes, self.axis, self.impute, discrete, means) @@ -748,7 +753,6 @@ def compute_distances(self, x1, x2): x2 is not None) else: nans1 = _distance.any_nan_row(x1.T) - self.check_no_two_tables(x2) return _distance.jaccard_cols( nonzeros1, x1, nans1, self.ps) From 13b7b7a757bf70540050b85f90f32e67a8a8534e Mon Sep 17 00:00:00 2001 From: janezd Date: Thu, 20 Jul 2017 17:07:34 +0200 Subject: [PATCH 23/27] distances: docstrings --- Orange/distance/__init__.py | 265 +++++++++++++++++++++++++----------- 1 file changed, 188 insertions(+), 77 deletions(-) diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 265d5c6d35f..069fc8fb897 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -53,7 +53,7 @@ def _orange_to_numpy(x): """ Return :class:`numpy.ndarray` (dense or sparse) with attribute data from the given instance of :class:`Orange.data.Table`, - :class:`Orange.data.RowInstance` or :class:`Orange.data.Instance`. . + :class:`Orange.data.RowInstance` or :class:`Orange.data.Instance`. """ if isinstance(x, Table): return x.X @@ -171,21 +171,17 @@ def __new__(cls, e1=None, e2=None, axis=1, impute=False, **kwargs): return model(e1, e2) def fit(self, e1): - """ - Return a :obj:`DistanceModel` fit to the data. Must be implemented in - subclasses. - - Args: - e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or - :obj:`np.ndarray` or `None`: - data on which to train the model and compute the distances - - Returns: `DistanceModel` - """ + """Abstract method returning :obj:`DistanceModel` fit to the data""" pass @staticmethod def check_no_discrete(n_vals): + """ + Raise an exception if there are any discrete attributes. + + Args: + n_vals (list of int): number of attributes values, 0 for continuous + """ if any(n_vals): raise ValueError("columns with discrete values are incommensurable") @@ -252,32 +248,20 @@ def __call__(self, e1, e2=None): def compute_distances(self, x1, x2): """ - Compute the distance between rows or colums of `x1`, or between rows - of `x1` and `x2`. This method must be implement by subclasses. Do not - call directly.""" + Abstract method for computation of distances between rows or colums of + `x1`, or between rows of `x1` and `x2`. Do not call directly.""" pass class FittedDistanceModel(DistanceModel): """ - Convenient common parent class for distance models with separate methods - for fitting and for computation of distances across rows and columns. - - Results of fitting are packed into a dictionary for easier passing to - Cython function that do the heavy lifting in these classes. + Base class for models that store attribute-related data for normalization + and imputation, and that treat discrete and continuous columns separately. Attributes: attributes (list of `Variable`): attributes on which the model was fit discrete (np.ndarray): bool array indicating discrete attributes continuous (np.ndarray): bool array indicating continuous attributes - - Class attributes: - distance_by_cols: a function that accepts a numpy array and parameters - and returns distances by columns. Usually a Cython function. - distance_by_rows: a function that accepts one or two numpy arrays, - an indicator whether the distances are to be computed within - a single array or between two arrays, and parameters; and - returns distances by columns. Usually a Cython function. """ def __init__(self, attributes, axis=1, impute=False): super().__init__(axis, impute) @@ -290,6 +274,22 @@ def __call__(self, e1, e2=None): return super().__call__(e1, e2) def continuous_columns(self, x1, x2, offset, scale): + """ + Extract and scale continuous columns from data tables. + If the second table is None, it defaults to the first table. + + Values are scaled if `self.normalize` is `True`. + + Args: + x1 (np.ndarray): first table + x2 (np.ndarray or None): second table + offset (float): a constant (e.g. mean, median) subtracted from data + scale: (float): divider (e.g. deviation) + + Returns: + data1 (np.ndarray): scaled continuous columns from `x1` + data2 (np.ndarray): scaled continuous columns from `x2` or `x1` + """ if self.continuous.all() and not self.normalize: data1, data2 = x1, x2 else: @@ -309,6 +309,10 @@ def continuous_columns(self, x1, x2, offset, scale): return data1, data2 def discrete_columns(self, x1, x2): + """ + Return discrete columns from the given tables. + If the second table is None, it defaults to the first table. + """ if self.discrete.all(): data1, data2 = x1, x1 if x2 is None else x2 else: @@ -319,21 +323,26 @@ def discrete_columns(self, x1, x2): class FittedDistance(Distance): """ - Convenient common parent class for distancess with separate methods for - fitting and for computation of distances across rows and columns. - Results of fitting are packed into a dictionary for easier passing to - Cython function that do the heavy lifting in these classes. + Base class for fitting models that store attribute-related data for + normalization and imputation, and that treat discrete and continuous + columns separately. The class implements a method `fit` that calls either `fit_columns` or `fit_rows` with the data and the number of values for discrete - attributes. + attributes. The provided method `fit_rows` calls methods + `get_discrete_stats` and `get_continuous_stats` that can be implemented + in derived classes. - Class attribute `ModelType` contains the type of the model returned by - `fit`. + Class attribute `rows_model_type` contains the type of the model returned by + `fit_rows`. """ rows_model_type = None #: Option[FittedDistanceModel] def fit(self, data): + """ + Prepare the data on attributes, call `fit_cols` or `fit_rows` and + return the resulting model. + """ attributes = data.domain.attributes x = _orange_to_numpy(data) n_vals = np.fromiter( @@ -342,24 +351,41 @@ def fit(self, data): dtype=np.int32, count=len(attributes)) return [self.fit_cols, self.fit_rows][self.axis](attributes, x, n_vals) + def fit_cols(self, attributes, x, n_vals): + """ + Return DistanceModel for computation of distances between columns. + Derived classes must define this method. + + Args: + attributes (list of Orange.data.Variable): list of attributes + x (np.ndarray): data + n_vals (np.ndarray): number of attribute values, 0 for continuous + """ + pass + def fit_rows(self, attributes, x, n_vals): """ - Compute statistics needed for normalization and for handling - missing data for row distances. Returns a dictionary with the - following keys: + Return a DistanceModel for computation of distances between rows. + + The model type is `self.row_distance_model`. It stores the data for + imputation of discrete and continuous values, and for normalization + of continuous values. Typical examples are the Euclidean and Manhattan + distance, for which the following data is stored: + + For continuous columns: + + - offsets[col] is the number subtracted from values in column `col` + - scales[col] is the divisor for values in columns `col` + - dist_missing2_cont[col]: the value used for distance between two + missing values in column `col` - - means: a means of numeric columns; undefined for discrete - - vars: variances of numeric columns, -1 for discrete, -2 to ignore - - dist_missing: a 2d-array; dist_missing[col, value] is the distance - added for the given `value` in discrete column `col` if the value - for the other row is missing; undefined for numeric columns - - dist_missing2: the value used for distance if both values are missing; - used for discrete and numeric columns - - normalize: set to `self.normalize`, so it is passed to the Cython - function + For discrete values: - A column is marked to be ignored if all its values are nan or if - `self.normalize` is `True` and the variance of the column is 0. + - dist_missing_disc[col, value] is the distance added for the given + `value` in the column `col` if the value for the other row is + missing + - dist_missing2_disc[col]: the distance between two missing values in + column `col` """ n_cols = len(n_vals) @@ -403,16 +429,44 @@ def fit_rows(self, attributes, x, n_vals): dist_missing_disc, dist_missing2_disc) def get_discrete_stats(self, column, n_bins): + """ + Return tables used computing distance between missing discrete values. + + Args: + column (np.ndarray): column data + n_bins (int): maximal number of bins in the data set + + Returns: + dist_missing_disc (np.ndarray): `dist_missing_disc[value]` is + 1 - probability of `value`, which is used as the distance added + for the given `value` in the column `col` if the value for the + other row is missing + dist_missing2_disc (float): the distance between two missing + values in this columns + """ dist = util.bincount(column, minlength=n_bins)[0] dist /= max(1, sum(dist)) return 1 - dist, 1 - np.sum(dist ** 2) def get_continuous_stats(self, column): + """ + Compute statistics for imputation and normalization of continuous data. + Derived classes must define this method. + + Args: + column (np.ndarray): column data + + Returns: + offset (float): the number subtracted from values in column + scales (float): the divisor for values in column + dist_missing2_cont (float): the value used for distance between two + missing values in column + """ pass # Fallbacks for distances in sparse data -# To be removed as the corresponding functionality is implemented above +# To be removed as the corresponding functionality is implemented properly class SklDistance: """ @@ -443,6 +497,12 @@ def __call__(self, e1, e2=None, axis=1, impute=False): class EuclideanRowsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between rows. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ def __init__(self, attributes, impute, normalize, continuous, discrete, means, vars, dist_missing2_cont, @@ -458,6 +518,16 @@ def __init__(self, attributes, impute, normalize, self.dist_missing2_disc = dist_missing2_disc def compute_distances(self, x1, x2=None): + """ + The method + - extracts normalized continuous attributes and then uses `row_norms` + and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 + (the trick from sklearn); + - calls a function in Cython that recomputes the distances between pairs + of rows that yielded nan + - calls a function in Cython that adds the contributions of discrete + columns + """ if self.continuous.any(): data1, data2 = self.continuous_columns( x1, x2, self.means, np.sqrt(2 * self.vars)) @@ -494,6 +564,12 @@ def compute_distances(self, x1, x2=None): class EuclideanColumnsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between columns. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ def __init__(self, attributes, impute, normalize, means, vars): super().__init__(attributes, 0, impute) self.normalize = normalize @@ -502,8 +578,6 @@ def __init__(self, attributes, impute, normalize, means, vars): def compute_distances(self, x1, x2=None): """ - Compute distances between columns of x1. - The method - extracts normalized continuous attributes and then uses `row_norms` and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 @@ -541,6 +615,11 @@ def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def get_continuous_stats(self, column): + """ + Return mean, variance and distance betwwen pairs of missing values + for the given columns. The method is called by inherited `fit_rows` + to construct a row-distance model + """ mean = util.nanmean(column) var = util.nanvar(column) if self.normalize: @@ -555,14 +634,8 @@ def get_continuous_stats(self, column): def fit_cols(self, attributes, x, n_vals): """ - Compute statistics needed for normalization and for handling - missing data for columns. Returns a dictionary with the - following keys: - - - means: column means - - vars: column variances - - normalize: set to self.normalize, so it is passed to the Cython - function + Return `EuclideanColumnsModel` with stored means and variances + for normalization and imputation. """ self.check_no_discrete(n_vals) means = np.nanmean(x, axis=0) @@ -574,6 +647,12 @@ def fit_cols(self, attributes, x, n_vals): class ManhattanRowsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between rows. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ def __init__(self, attributes, impute, normalize, continuous, discrete, medians, mads, dist_missing2_cont, @@ -589,6 +668,14 @@ def __init__(self, attributes, impute, normalize, self.dist_missing2_disc = dist_missing2_disc def compute_distances(self, x1, x2): + """ + The method + - extracts normalized continuous attributes and computes distances + ignoring the possibility of nans + - recomputes the distances between pairs of rows that yielded nans + - adds the contributions of discrete columns using the same function as + the Euclidean distance + """ if self.continuous.any(): data1, data2 = self.continuous_columns( x1, x2, self.medians, 2 * self.mads) @@ -617,7 +704,12 @@ def compute_distances(self, x1, x2): class ManhattanColumnsModel(FittedDistanceModel): - distance_by_cols = _distance.manhattan_cols + """ + Model for computation of Manhattan distances between columns. + + Medians are used as offsets for normalization, and two MADS are + used for scaling. + """ def __init__(self, attributes, impute, normalize, medians, mads): super().__init__(attributes, 0, impute) @@ -644,6 +736,11 @@ def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) def get_continuous_stats(self, column): + """ + Return median, MAD and distance betwwen pairs of missing values + for the given columns. The method is called by inherited `fit_rows` + to construct a row-distance model + """ median = np.nanmedian(column) mad = np.nanmedian(np.abs(column - median)) if self.normalize: @@ -658,14 +755,8 @@ def get_continuous_stats(self, column): def fit_cols(self, attributes, x, n_vals): """ - Compute statistics needed for normalization and for handling - missing data for columns. Returns a dictionary with the - following keys: - - - medians: column medians - - mads: medians of absolute distances from medians - - normalize: set to self.normalize, so it is passed to the Cython - function + Return `ManhattanColumnsModel` with stored medians and MADs + for normalization and imputation. """ self.check_no_discrete(n_vals) medians = np.nanmedian(x, axis=0) @@ -685,6 +776,7 @@ class Cosine(FittedDistance): @staticmethod def discrete_to_indicators(x, discrete): + """Change non-zero values of discrete attributes to 1.""" if discrete.any(): x = x.copy() for col, disc in enumerate(discrete): @@ -693,6 +785,8 @@ def discrete_to_indicators(x, discrete): return x def fit_rows(self, attributes, x, n_vals): + """Return a model for cosine distances with stored means for imputation + """ discrete = n_vals > 0 x = self.discrete_to_indicators(x, discrete) means = util.nanmean(x, axis=0) @@ -703,12 +797,21 @@ def fit_rows(self, attributes, x, n_vals): fit_cols = fit_rows class CosineModel(FittedDistanceModel): + """Model for computation of cosine distances across rows and columns. + All non-zero discrete values are treated as 1.""" def __init__(self, attributes, axis, impute, discrete, means): super().__init__(attributes, axis, impute) self.discrete = discrete self.means = means def compute_distances(self, x1, x2): + """ + The method imputes the missing values as means and calls + safe_sparse_dot. Imputation simplifies computation at a cost of + (theoretically) slightly wrong distance between pairs of missing + values. + """ + def prepare_data(x): if self.discrete.any(): data = Cosine.discrete_to_indicators(x, self.discrete) @@ -732,11 +835,25 @@ def prepare_data(x): class JaccardModel(FittedDistanceModel): + """ + Model for computation of cosine distances across rows and columns. + All non-zero values are treated as 1. + """ def __init__(self, attributes, axis, impute, ps): super().__init__(attributes, axis, impute) self.ps = ps def compute_distances(self, x1, x2): + """ + The method uses a function implemented in Cython. Data (`x1` and `x2`) + is accompanied by two tables. One is a 2-d table in which elements of + `x1` (`x2`) are replaced by 0's and 1's. The other is a vector + indicating rows (or column) with nan values. + + The function in Cython uses a fast loop without any conditions to + compute distances between rows without missing values, and a slower + loop for those with missing values. + """ nonzeros1 = np.not_equal(x1, 0).view(np.int8) if self.axis == 1: nans1 = _distance.any_nan_row(x1) @@ -764,15 +881,9 @@ class Jaccard(FittedDistance): def fit_rows(self, attributes, x, n_vals): """ - Compute statistics needed for normalization and for handling - missing data for row and column based distances. Although the - computation is asymmetric, the same statistics are needed in both cases. - - Returns a dictionary with the following key: - - - ps: relative frequencies of non-zero values + Return a model for computation of Jaccard values. The model stores + frequencies of non-zero values per each column. """ - ps = np.fromiter( (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), dtype=np.double, count=len(n_vals)) From 62a5072aa038fa13e711db8d1f3ca607b90a8024 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 21 Jul 2017 09:59:41 +0200 Subject: [PATCH 24/27] distances: Refactor into separate files --- Orange/distance/__init__.py | 1018 +------------------------------- Orange/distance/base.py | 491 +++++++++++++++ Orange/distance/distance.py | 529 +++++++++++++++++ Orange/tests/test_distances.py | 2 + 4 files changed, 1027 insertions(+), 1013 deletions(-) create mode 100644 Orange/distance/base.py create mode 100644 Orange/distance/distance.py diff --git a/Orange/distance/__init__.py b/Orange/distance/__init__.py index 069fc8fb897..4f998778aac 100644 --- a/Orange/distance/__init__.py +++ b/Orange/distance/__init__.py @@ -1,1014 +1,6 @@ -import numpy as np -from scipy import stats -import sklearn.metrics as skl_metrics -from sklearn.utils.extmath import row_norms, safe_sparse_dot +from .distance import (Distance, DistanceModel, + Euclidean, Manhattan, Cosine, Jaccard, + SpearmanR, SpearmanRAbsolute, PearsonR, PearsonRAbsolute, + Mahalanobis, MahalanobisDistance) -from Orange.data import Table, Domain, Instance, RowInstance -from Orange.misc import DistMatrix -from Orange.distance import _distance -from Orange.statistics import util -from Orange.preprocess import SklImpute - -__all__ = ['Euclidean', 'Manhattan', 'Cosine', 'Jaccard', 'SpearmanR', - 'SpearmanRAbsolute', 'PearsonR', 'PearsonRAbsolute', 'Mahalanobis', - 'MahalanobisDistance'] - -# TODO: When we upgrade to numpy 1.13, change use argument copy=False in -# nan_to_num instead of assignment - -# TODO this *private* function is called from several widgets to prepare -# data for calling the below classes. After we (mostly) stopped relying -# on sklearn.metrics, this is (mostly) unnecessary -def _preprocess(table, impute=True): - """Remove categorical attributes and impute missing values.""" - if not len(table): - return table - new_domain = Domain( - [a for a in table.domain.attributes if a.is_continuous], - table.domain.class_vars, - table.domain.metas) - new_data = table.transform(new_domain) - if impute: - new_data = SklImpute()(new_data) - return new_data - - -# TODO I have put this function here as a substitute the above `_preprocess`. -# None of them really belongs here; (re?)move them, eventually. -def remove_discrete_features(data): - """Remove discrete columns from the data.""" - new_domain = Domain( - [a for a in data.domain.attributes if a.is_continuous], - data.domain.class_vars, - data.domain.metas) - return data.transform(new_domain) - - -def impute(data): - """Impute missing values.""" - return SklImpute()(data) - - -def _orange_to_numpy(x): - """ - Return :class:`numpy.ndarray` (dense or sparse) with attribute data - from the given instance of :class:`Orange.data.Table`, - :class:`Orange.data.RowInstance` or :class:`Orange.data.Instance`. - """ - if isinstance(x, Table): - return x.X - elif isinstance(x, Instance): - return np.atleast_2d(x.x) - elif isinstance(x, np.ndarray): - return np.atleast_2d(x) - else: - return x # e.g. None - - -class Distance: - # Argument types in docstrings must be in a single line(?), hence - # pylint: disable=line-too-long - """ - Base class for construction of distances models (:obj:`DistanceModel`). - - Distances can be computed between all pairs of rows in one table, or - between pairs where one row is from one table and one from another. - - If `axis` is set to `0`, the class computes distances between all pairs - of columns in a table. Distances between columns from separate tables are - probably meaningless, thus unsupported. - - The class can be used as follows: - - - Constructor is called only with keyword argument `axis` that - specifies the axis over which the distances are computed, and with other - subclass-specific keyword arguments. - - Next, we call the method `fit(data)` to produce an instance of - :obj:`DistanceModel`; the instance stores any parameters needed for - computation of distances, such as statistics for normalization and - handling of missing data. - - We can then call the :obj:`DistanceModel` with data to compute the - distance between its rows or columns, or with two data tables to - compute distances between all pairs of rows. - - The second, shorter way to use this class is to call the constructor with - one or two data tables and any additional keyword arguments. Constructor - will execute the above steps and return :obj:`~Orange.misc.DistMatrix`. - Such usage is here for backward compatibility, practicality and efficiency. - - Args: - e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`): - data on which to train the model and compute the distances - e2 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or :obj:`np.ndarray` or `None`): - if present, the class computes distances with pairs coming from - the two tables - axis (int): - axis over which the distances are computed, 1 (default) for - rows, 0 for columns - impute (bool): - if `True` (default is `False`), nans in the computed distances - are replaced with zeros, and infs with very large numbers. - - Attributes: - axis (int): - axis over which the distances are computed, 1 (default) for - rows, 0 for columns - impute (bool): - if `True` (default is `False`), nans in the computed distances - are replaced with zeros, and infs with very large numbers. - - The capabilities of the metrics are described with class attributes. - - If class attribute `supports_discrete` is `True`, the distance - also uses discrete attributes to compute row distances. The use of discrete - attributes depends upon the type of distance; e.g. Jaccard distance observes - whether the value is zero or non-zero, while Euclidean and Manhattan - distance observes whether a pair of values is same or different. - - Class attribute `supports_missing` indicates that the distance can cope - with missing data. In such cases, letting the distance handle it should - be preferred over pre-imputation of missing values. - - Class attribute `supports_normalization` indicates that the constructor - accepts an argument `normalize`. If set to `True`, the metric will attempt - to normalize the values in a sense that each attribute will have equal - influence. For instance, the Euclidean distance subtract the mean and - divides the result by the deviation, while Manhattan distance uses the - median and MAD. - - If class attribute `supports_sparse` is `True`, the class will handle - sparse data. Currently, all classes that do handle it rely on fallbacks to - SKL metrics. These, however, do not support discrete data and missing - values, and will fail silently. - """ - supports_sparse = False - supports_discrete = False - supports_normalization = False - supports_missing = True - - def __new__(cls, e1=None, e2=None, axis=1, impute=False, **kwargs): - self = super().__new__(cls) - self.axis = axis - self.impute = impute - # Ugly, but needed to allow allow setting subclass-specific parameters - # (such as normalize) when `e1` is not `None` and the `__new__` in the - # subclass is skipped - self.__dict__.update(**kwargs) - if e1 is None: - return self - - # Fallbacks for sparse data and numpy tables. Remove when subclasses - # no longer use fallbacks for sparse data, and handling numpy tables - # becomes obsolete (or handled elsewhere) - if (not hasattr(e1, "domain") - or hasattr(e1, "is_sparse") and e1.is_sparse()): - fallback = getattr(self, "fallback", None) - if fallback is not None: - return fallback(e1, e2, axis, impute) - - # Magic constructor - model = self.fit(e1) - return model(e1, e2) - - def fit(self, e1): - """Abstract method returning :obj:`DistanceModel` fit to the data""" - pass - - @staticmethod - def check_no_discrete(n_vals): - """ - Raise an exception if there are any discrete attributes. - - Args: - n_vals (list of int): number of attributes values, 0 for continuous - """ - if any(n_vals): - raise ValueError("columns with discrete values are incommensurable") - - -class DistanceModel: - """ - Base class for classes that compute distances between data rows or columns. - Instances of these classes are not constructed directly but returned by - the corresponding instances of :obj:`Distance`. - - Attributes: - axis (int, readonly): - axis over which the distances are computed, 1 (default) for - rows, 0 for columns - impute (bool): - if `True` (default is `False`), nans in the computed distances - are replaced with zeros, and infs with very large numbers - - """ - def __init__(self, axis, impute=False): - self._axis = axis - self.impute = impute - - @property - def axis(self): - return self._axis - - def __call__(self, e1, e2=None): - """ - If e2 is omitted, calculate distances between all rows (axis=1) or - columns (axis=2) of e1. If e2 is present, calculate distances between - all pairs if rows from e1 and e2. - - This method converts the data into numpy arrays, calls the method - `compute_data` and packs the result into `DistMatrix`. Subclasses are - expected to define the `compute_data` and not the `__call__` method. - - Args: - e1 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): - input data - e2 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): - secondary data - - Returns: - A distance matrix (Orange.misc.distmatrix.DistMatrix) - """ - if self.axis == 0 and e2 is not None: - # Backward compatibility fix - if e2 is e1: - e2 = None - else: - raise ValueError("Two tables cannot be compared by columns") - - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) - dist = self.compute_distances(x1, x2) - if self.impute and np.isnan(dist).any(): - dist = np.nan_to_num(dist) - if isinstance(e1, Table) or isinstance(e1, RowInstance): - dist = DistMatrix(dist, e1, e2, self.axis) - else: - dist = DistMatrix(dist) - return dist - - def compute_distances(self, x1, x2): - """ - Abstract method for computation of distances between rows or colums of - `x1`, or between rows of `x1` and `x2`. Do not call directly.""" - pass - - -class FittedDistanceModel(DistanceModel): - """ - Base class for models that store attribute-related data for normalization - and imputation, and that treat discrete and continuous columns separately. - - Attributes: - attributes (list of `Variable`): attributes on which the model was fit - discrete (np.ndarray): bool array indicating discrete attributes - continuous (np.ndarray): bool array indicating continuous attributes - """ - def __init__(self, attributes, axis=1, impute=False): - super().__init__(axis, impute) - self.attributes = attributes - - def __call__(self, e1, e2=None): - if e1.domain.attributes != self.attributes or \ - e2 is not None and e2.domain.attributes != self.attributes: - raise ValueError("mismatching domains") - return super().__call__(e1, e2) - - def continuous_columns(self, x1, x2, offset, scale): - """ - Extract and scale continuous columns from data tables. - If the second table is None, it defaults to the first table. - - Values are scaled if `self.normalize` is `True`. - - Args: - x1 (np.ndarray): first table - x2 (np.ndarray or None): second table - offset (float): a constant (e.g. mean, median) subtracted from data - scale: (float): divider (e.g. deviation) - - Returns: - data1 (np.ndarray): scaled continuous columns from `x1` - data2 (np.ndarray): scaled continuous columns from `x2` or `x1` - """ - if self.continuous.all() and not self.normalize: - data1, data2 = x1, x2 - else: - data1 = x1[:, self.continuous] - if x2 is not None: - data2 = x2[:, self.continuous] - if self.normalize: - data1 = x1[:, self.continuous] - data1 -= offset - data1 /= scale - if x2 is not None: - data2 = x2[:, self.continuous] - data2 -= offset - data2 /= scale - if x2 is None: - data2 = data1 - return data1, data2 - - def discrete_columns(self, x1, x2): - """ - Return discrete columns from the given tables. - If the second table is None, it defaults to the first table. - """ - if self.discrete.all(): - data1, data2 = x1, x1 if x2 is None else x2 - else: - data1 = x1[:, self.discrete] - data2 = data1 if x2 is None else x2[:, self.discrete] - return data1, data2 - - -class FittedDistance(Distance): - """ - Base class for fitting models that store attribute-related data for - normalization and imputation, and that treat discrete and continuous - columns separately. - - The class implements a method `fit` that calls either `fit_columns` - or `fit_rows` with the data and the number of values for discrete - attributes. The provided method `fit_rows` calls methods - `get_discrete_stats` and `get_continuous_stats` that can be implemented - in derived classes. - - Class attribute `rows_model_type` contains the type of the model returned by - `fit_rows`. - """ - rows_model_type = None #: Option[FittedDistanceModel] - - def fit(self, data): - """ - Prepare the data on attributes, call `fit_cols` or `fit_rows` and - return the resulting model. - """ - attributes = data.domain.attributes - x = _orange_to_numpy(data) - n_vals = np.fromiter( - (len(attr.values) if attr.is_discrete else 0 - for attr in attributes), - dtype=np.int32, count=len(attributes)) - return [self.fit_cols, self.fit_rows][self.axis](attributes, x, n_vals) - - def fit_cols(self, attributes, x, n_vals): - """ - Return DistanceModel for computation of distances between columns. - Derived classes must define this method. - - Args: - attributes (list of Orange.data.Variable): list of attributes - x (np.ndarray): data - n_vals (np.ndarray): number of attribute values, 0 for continuous - """ - pass - - def fit_rows(self, attributes, x, n_vals): - """ - Return a DistanceModel for computation of distances between rows. - - The model type is `self.row_distance_model`. It stores the data for - imputation of discrete and continuous values, and for normalization - of continuous values. Typical examples are the Euclidean and Manhattan - distance, for which the following data is stored: - - For continuous columns: - - - offsets[col] is the number subtracted from values in column `col` - - scales[col] is the divisor for values in columns `col` - - dist_missing2_cont[col]: the value used for distance between two - missing values in column `col` - - For discrete values: - - - dist_missing_disc[col, value] is the distance added for the given - `value` in the column `col` if the value for the other row is - missing - - dist_missing2_disc[col]: the distance between two missing values in - column `col` - """ - n_cols = len(n_vals) - - discrete = n_vals > 0 - n_bins = max(n_vals, default=0) - n_discrete = sum(discrete) - dist_missing_disc = np.zeros((n_discrete, n_bins), dtype=float) - dist_missing2_disc = np.zeros(n_discrete, dtype=float) - - continuous = ~discrete - n_continuous = sum(continuous) - offsets = np.zeros(n_continuous, dtype=float) - scales = np.empty(n_continuous, dtype=float) - dist_missing2_cont = np.zeros(n_continuous, dtype=float) - - curr_disc = curr_cont = 0 - for col in range(n_cols): - column = x[:, col] - if np.isnan(column).all(): - continuous[col] = discrete[col] = False - elif discrete[col]: - discrete_stats = self.get_discrete_stats(column, n_bins) - if discrete_stats is not None: - dist_missing_disc[curr_disc], \ - dist_missing2_disc[curr_disc] = discrete_stats - curr_disc += 1 - else: - continuous_stats = self.get_continuous_stats(column) - if continuous_stats is not None: - offsets[curr_cont], scales[curr_cont],\ - dist_missing2_cont[curr_cont] = continuous_stats - curr_cont += 1 - else: - continuous[col] = False - # pylint: disable=not-callable - return self.rows_model_type( - attributes, impute, getattr(self, "normalize", False), - continuous, discrete, - offsets[:curr_cont], scales[:curr_cont], - dist_missing2_cont[:curr_cont], - dist_missing_disc, dist_missing2_disc) - - def get_discrete_stats(self, column, n_bins): - """ - Return tables used computing distance between missing discrete values. - - Args: - column (np.ndarray): column data - n_bins (int): maximal number of bins in the data set - - Returns: - dist_missing_disc (np.ndarray): `dist_missing_disc[value]` is - 1 - probability of `value`, which is used as the distance added - for the given `value` in the column `col` if the value for the - other row is missing - dist_missing2_disc (float): the distance between two missing - values in this columns - """ - dist = util.bincount(column, minlength=n_bins)[0] - dist /= max(1, sum(dist)) - return 1 - dist, 1 - np.sum(dist ** 2) - - def get_continuous_stats(self, column): - """ - Compute statistics for imputation and normalization of continuous data. - Derived classes must define this method. - - Args: - column (np.ndarray): column data - - Returns: - offset (float): the number subtracted from values in column - scales (float): the divisor for values in column - dist_missing2_cont (float): the value used for distance between two - missing values in column - """ - pass - - -# Fallbacks for distances in sparse data -# To be removed as the corresponding functionality is implemented properly - -class SklDistance: - """ - Wrapper for functions sklearn's metrics. Used only as temporary fallbacks - when `Euclidean`, `Manhattan`, `Cosine` or `Jaccard` are given sparse data - or raw numpy arrays. These classes can't handle discrete or missing data - and normalization. Do not use for wrapping new classes. - """ - def __init__(self, metric): - self.metric = metric - - def __call__(self, e1, e2=None, axis=1, impute=False): - x1 = _orange_to_numpy(e1) - x2 = _orange_to_numpy(e2) - if axis == 0: - x1 = x1.T - if x2 is not None: - x2 = x2.T - dist = skl_metrics.pairwise.pairwise_distances( - x1, x2, metric=self.metric) - if impute and np.isnan(dist).any(): - dist = np.nan_to_num(dist) - if isinstance(e1, Table) or isinstance(e1, RowInstance): - dist_matrix = DistMatrix(dist, e1, e2, axis) - else: - dist_matrix = DistMatrix(dist) - return dist_matrix - - -class EuclideanRowsModel(FittedDistanceModel): - """ - Model for computation of Euclidean distances between rows. - - Means are used as offsets for normalization, and two deviations are - used for scaling. - """ - def __init__(self, attributes, impute, normalize, - continuous, discrete, - means, vars, dist_missing2_cont, - dist_missing_disc, dist_missing2_disc): - super().__init__(attributes, 1, impute) - self.normalize = normalize - self.continuous = continuous - self.discrete = discrete - self.means = means - self.vars = vars - self.dist_missing2_cont = dist_missing2_cont - self.dist_missing_disc = dist_missing_disc - self.dist_missing2_disc = dist_missing2_disc - - def compute_distances(self, x1, x2=None): - """ - The method - - extracts normalized continuous attributes and then uses `row_norms` - and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 - (the trick from sklearn); - - calls a function in Cython that recomputes the distances between pairs - of rows that yielded nan - - calls a function in Cython that adds the contributions of discrete - columns - """ - if self.continuous.any(): - data1, data2 = self.continuous_columns( - x1, x2, self.means, np.sqrt(2 * self.vars)) - - # adapted from sklearn.metric.euclidean_distances - xx = row_norms(data1, squared=True)[:, np.newaxis] - if x2 is not None: - yy = row_norms(data2, squared=True)[np.newaxis, :] - else: - yy = xx.T - distances = safe_sparse_dot(data1, data2.T, dense_output=True) - distances *= -2 - distances += xx - distances += yy - np.maximum(distances, 0, out=distances) - if x2 is None: - distances.flat[::distances.shape[0] + 1] = 0.0 - fixer = [_distance.fix_euclidean_rows, - _distance.fix_euclidean_rows_normalized][self.normalize] - fixer(distances, data1, data2, - self.means, self.vars, self.dist_missing2_cont, - x2 is not None) - else: - distances = np.zeros((x1.shape[0], - (x2 if x2 is not None else x1).shape[0])) - - if np.any(self.discrete): - data1, data2 = self.discrete_columns(x1, x2) - _distance.euclidean_rows_discrete( - distances, data1, data2, self.dist_missing_disc, - self.dist_missing2_disc, x2 is not None) - - return np.sqrt(distances) - - -class EuclideanColumnsModel(FittedDistanceModel): - """ - Model for computation of Euclidean distances between columns. - - Means are used as offsets for normalization, and two deviations are - used for scaling. - """ - def __init__(self, attributes, impute, normalize, means, vars): - super().__init__(attributes, 0, impute) - self.normalize = normalize - self.means = means - self.vars = vars - - def compute_distances(self, x1, x2=None): - """ - The method - - extracts normalized continuous attributes and then uses `row_norms` - and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 - (the trick from sklearn); - - calls a function in Cython that adds the contributions of discrete - columns - """ - if self.normalize: - x1 = x1 - self.means - x1 /= np.sqrt(2 * self.vars) - - # adapted from sklearn.metric.euclidean_distances - xx = row_norms(x1.T, squared=True)[:, np.newaxis] - distances = safe_sparse_dot(x1.T, x1, dense_output=True) - distances *= -2 - distances += xx - distances += xx.T - np.maximum(distances, 0, out=distances) - distances.flat[::distances.shape[0] + 1] = 0.0 - - fixer = [_distance.fix_euclidean_cols, - _distance.fix_euclidean_cols_normalized][self.normalize] - fixer(distances, x1, self.means, self.vars) - return np.sqrt(distances) - - -class Euclidean(FittedDistance): - supports_sparse = True # via fallback - supports_discrete = True - supports_normalization = True - fallback = SklDistance('euclidean') - rows_model_type = EuclideanRowsModel - - def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): - return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) - - def get_continuous_stats(self, column): - """ - Return mean, variance and distance betwwen pairs of missing values - for the given columns. The method is called by inherited `fit_rows` - to construct a row-distance model - """ - mean = util.nanmean(column) - var = util.nanvar(column) - if self.normalize: - if var == 0: - return None - dist_missing2_cont = 1 - else: - dist_missing2_cont = 2 * var - if np.isnan(dist_missing2_cont): - dist_missing2_cont = 0 - return mean, var, dist_missing2_cont - - def fit_cols(self, attributes, x, n_vals): - """ - Return `EuclideanColumnsModel` with stored means and variances - for normalization and imputation. - """ - self.check_no_discrete(n_vals) - means = np.nanmean(x, axis=0) - vars = np.nanvar(x, axis=0) - if self.normalize and (np.isnan(vars).any() or not vars.all()): - raise ValueError("some columns are constant or have no values") - return EuclideanColumnsModel( - attributes, self.impute, self.normalize, means, vars) - - -class ManhattanRowsModel(FittedDistanceModel): - """ - Model for computation of Euclidean distances between rows. - - Means are used as offsets for normalization, and two deviations are - used for scaling. - """ - def __init__(self, attributes, impute, normalize, - continuous, discrete, - medians, mads, dist_missing2_cont, - dist_missing_disc, dist_missing2_disc): - super().__init__(attributes, 1, impute) - self.normalize = normalize - self.continuous = continuous - self.discrete = discrete - self.medians = medians - self.mads = mads - self.dist_missing2_cont = dist_missing2_cont - self.dist_missing_disc = dist_missing_disc - self.dist_missing2_disc = dist_missing2_disc - - def compute_distances(self, x1, x2): - """ - The method - - extracts normalized continuous attributes and computes distances - ignoring the possibility of nans - - recomputes the distances between pairs of rows that yielded nans - - adds the contributions of discrete columns using the same function as - the Euclidean distance - """ - if self.continuous.any(): - data1, data2 = self.continuous_columns( - x1, x2, self.medians, 2 * self.mads) - distances = _distance.manhattan_rows_cont( - data1, data2, x2 is not None) - if self.normalize: - _distance.fix_manhattan_rows_normalized( - distances, data1, data2, x2 is not None) - else: - _distance.fix_manhattan_rows( - distances, data1, data2, - self.medians, self.mads, self.dist_missing2_cont, - x2 is not None) - else: - distances = np.zeros((x1.shape[0], - (x2 if x2 is not None else x1).shape[0])) - - if np.any(self.discrete): - data1, data2 = self.discrete_columns(x1, x2) - # For discrete attributes, Euclidean is same as Manhattan - _distance.euclidean_rows_discrete( - distances, data1, data2, self.dist_missing_disc, - self.dist_missing2_disc, x2 is not None) - - return distances - - -class ManhattanColumnsModel(FittedDistanceModel): - """ - Model for computation of Manhattan distances between columns. - - Medians are used as offsets for normalization, and two MADS are - used for scaling. - """ - - def __init__(self, attributes, impute, normalize, medians, mads): - super().__init__(attributes, 0, impute) - self.normalize = normalize - self.medians = medians - self.mads = mads - - def compute_distances(self, x1, x2=None): - if self.normalize: - x1 = x1 - self.medians - x1 /= 2 - x1 /= self.mads - return _distance.manhattan_cols(x1, self.medians, self.mads, self.normalize) - - -class Manhattan(FittedDistance): - supports_sparse = True # via fallback - supports_discrete = True - supports_normalization = True - fallback = SklDistance('manhattan') - rows_model_type = ManhattanRowsModel - - def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): - return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) - - def get_continuous_stats(self, column): - """ - Return median, MAD and distance betwwen pairs of missing values - for the given columns. The method is called by inherited `fit_rows` - to construct a row-distance model - """ - median = np.nanmedian(column) - mad = np.nanmedian(np.abs(column - median)) - if self.normalize: - if mad == 0: - return None - dist_missing2_cont = 1 - else: - dist_missing2_cont = 2 * mad - if np.isnan(dist_missing2_cont): - dist_missing2_cont = 0 - return median, mad, dist_missing2_cont - - def fit_cols(self, attributes, x, n_vals): - """ - Return `ManhattanColumnsModel` with stored medians and MADs - for normalization and imputation. - """ - self.check_no_discrete(n_vals) - medians = np.nanmedian(x, axis=0) - mads = np.nanmedian(np.abs(x - medians), axis=0) - if self.normalize and (np.isnan(mads).any() or not mads.all()): - raise ValueError( - "some columns have zero absolute distance from median, " - "or no values") - return ManhattanColumnsModel( - attributes, self.impute, self.normalize, medians, mads) - - -class Cosine(FittedDistance): - supports_sparse = True # via fallback - supports_discrete = True - fallback = SklDistance('cosine') - - @staticmethod - def discrete_to_indicators(x, discrete): - """Change non-zero values of discrete attributes to 1.""" - if discrete.any(): - x = x.copy() - for col, disc in enumerate(discrete): - if disc: - x[:, col].clip(0, 1, out=x[:, col]) - return x - - def fit_rows(self, attributes, x, n_vals): - """Return a model for cosine distances with stored means for imputation - """ - discrete = n_vals > 0 - x = self.discrete_to_indicators(x, discrete) - means = util.nanmean(x, axis=0) - means = np.nan_to_num(means) - return self.CosineModel(attributes, self.axis, self.impute, - discrete, means) - - fit_cols = fit_rows - - class CosineModel(FittedDistanceModel): - """Model for computation of cosine distances across rows and columns. - All non-zero discrete values are treated as 1.""" - def __init__(self, attributes, axis, impute, discrete, means): - super().__init__(attributes, axis, impute) - self.discrete = discrete - self.means = means - - def compute_distances(self, x1, x2): - """ - The method imputes the missing values as means and calls - safe_sparse_dot. Imputation simplifies computation at a cost of - (theoretically) slightly wrong distance between pairs of missing - values. - """ - - def prepare_data(x): - if self.discrete.any(): - data = Cosine.discrete_to_indicators(x, self.discrete) - else: - data = x.copy() - for col, mean in enumerate(self.means): - column = data[:, col] - column[np.isnan(column)] = mean - if self.axis == 0: - data = data.T - data /= row_norms(data)[:, np.newaxis] - return data - - data1 = prepare_data(x1) - data2 = data1 if x2 is None else prepare_data(x2) - dist = safe_sparse_dot(data1, data2.T) - np.clip(dist, 0, 1, out=dist) - if x2 is None: - dist.flat[::dist.shape[0] + 1] = 1.0 - return 1 - dist - - -class JaccardModel(FittedDistanceModel): - """ - Model for computation of cosine distances across rows and columns. - All non-zero values are treated as 1. - """ - def __init__(self, attributes, axis, impute, ps): - super().__init__(attributes, axis, impute) - self.ps = ps - - def compute_distances(self, x1, x2): - """ - The method uses a function implemented in Cython. Data (`x1` and `x2`) - is accompanied by two tables. One is a 2-d table in which elements of - `x1` (`x2`) are replaced by 0's and 1's. The other is a vector - indicating rows (or column) with nan values. - - The function in Cython uses a fast loop without any conditions to - compute distances between rows without missing values, and a slower - loop for those with missing values. - """ - nonzeros1 = np.not_equal(x1, 0).view(np.int8) - if self.axis == 1: - nans1 = _distance.any_nan_row(x1) - if x2 is None: - nonzeros2, nans2 = nonzeros1, nans1 - else: - nonzeros2 = np.not_equal(x2, 0).view(np.int8) - nans2 = _distance.any_nan_row(x2) - return _distance.jaccard_rows( - nonzeros1, nonzeros2, - x1, x1 if x2 is None else x2, - nans1, nans2, - self.ps, - x2 is not None) - else: - nans1 = _distance.any_nan_row(x1.T) - return _distance.jaccard_cols( - nonzeros1, x1, nans1, self.ps) - -class Jaccard(FittedDistance): - supports_sparse = False - supports_discrete = True - fallback = SklDistance('jaccard') - ModelType = JaccardModel - - def fit_rows(self, attributes, x, n_vals): - """ - Return a model for computation of Jaccard values. The model stores - frequencies of non-zero values per each column. - """ - ps = np.fromiter( - (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), - dtype=np.double, count=len(n_vals)) - return JaccardModel(attributes, self.axis, self.impute, ps) - - fit_cols = fit_rows - - -class CorrelationDistanceModel(DistanceModel): - """Helper class for normal and absolute Pearson and Spearman correlation""" - def __init__(self, absolute, axis=1, impute=False): - super().__init__(axis, impute) - self.absolute = absolute - - def compute_distances(self, x1, x2): - if x2 is None: - x2 = x1 - rho = self.compute_correlation(x1, x2) - if self.absolute: - return (1. - np.abs(rho)) / 2. - else: - return (1. - rho) / 2. - - def compute_correlation(self, x1, x2): - pass - - -class SpearmanModel(CorrelationDistanceModel): - def compute_correlation(self, x1, x2): - rho = stats.spearmanr(x1, x2, axis=self.axis)[0] - if isinstance(rho, np.float): - return np.array([[rho]]) - slc = x1.shape[1 - self.axis] - return rho[:slc, slc:] - - -class CorrelationDistance(Distance): - supports_missing = False - - -class SpearmanR(CorrelationDistance): - def fit(self, _): - return SpearmanModel(False, self.axis, self.impute) - - -class SpearmanRAbsolute(CorrelationDistance): - def fit(self, _): - return SpearmanModel(True, self.axis, self.impute) - - -class PearsonModel(CorrelationDistanceModel): - def compute_correlation(self, x1, x2): - if self.axis == 0: - x1 = x1.T - x2 = x2.T - return np.array([[stats.pearsonr(i, j)[0] for j in x2] for i in x1]) - - -class PearsonR(CorrelationDistance): - def fit(self, _): - return PearsonModel(False, self.axis, self.impute) - - -class PearsonRAbsolute(CorrelationDistance): - def fit(self, _): - return PearsonModel(True, self.axis, self.impute) - - -class Mahalanobis(Distance): - supports_sparse = False - supports_missing = False - - def fit(self, data): - """Return a model with stored inverse covariance matrix""" - x = _orange_to_numpy(data) - if self.axis == 0: - x = x.T - try: - c = np.cov(x.T) - except: - raise MemoryError("Covariance matrix is too large.") - try: - vi = np.linalg.inv(c) - except: - raise ValueError("Computation of inverse covariance matrix failed.") - return MahalanobisModel(self.axis, self.impute, vi) - - -class MahalanobisModel(DistanceModel): - def __init__(self, axis, impute, vi): - super().__init__(axis, impute) - self.vi = vi - - def __call__(self, e1, e2=None, impute=None): - # argument `impute` is here just for backward compatibility; don't use - if impute is not None: - self.impute = impute - return super().__call__(e1, e2) - - def compute_distances(self, x1, x2): - if self.axis == 0: - x1 = x1.T - if x2 is not None: - x2 = x2.T - if x1.shape[1] != self.vi.shape[0] or \ - x2 is not None and x2.shape[1] != self.vi.shape[0]: - raise ValueError('Incorrect number of features.') - return skl_metrics.pairwise.pairwise_distances( - x1, x2, metric='mahalanobis', VI=self.vi) - - -# TODO: Appears to have been used only in the Distances widget (where it had -# to be handled as a special case and is now replaced with the above class) -# and in tests. Remove? -class MahalanobisDistance: - """ - Obsolete class needed for backward compatibility. - - Previous implementation of instances did not have a separate fitting phase, - except for MahalanobisDistance, which was implemented in a single class - but required first (explicitly) calling the method 'fit'. The backward - compatibility hack in :obj:`Distance` cannot handle such use, hence it - is provided in this class. - """ - def __new__(cls, data=None, axis=1, _='Mahalanobis'): - if data is None: - return cls - return Mahalanobis(axis=axis).fit(data) +from .base import _preprocess, remove_discrete_features, impute diff --git a/Orange/distance/base.py b/Orange/distance/base.py new file mode 100644 index 00000000000..2cf6f594f72 --- /dev/null +++ b/Orange/distance/base.py @@ -0,0 +1,491 @@ +import numpy as np +import sklearn.metrics as skl_metrics + +from Orange.data import Table, Domain, Instance, RowInstance +from Orange.misc import DistMatrix +from Orange.preprocess import SklImpute +from Orange.statistics import util + + +# TODO: When we upgrade to numpy 1.13, change use argument copy=False in +# nan_to_num instead of assignment + +# TODO this *private* function is called from several widgets to prepare +# data for calling the below classes. After we (mostly) stopped relying +# on sklearn.metrics, this is (mostly) unnecessary +def _preprocess(table, impute=True): + """Remove categorical attributes and impute missing values.""" + if not len(table): + return table + new_domain = Domain( + [a for a in table.domain.attributes if a.is_continuous], + table.domain.class_vars, + table.domain.metas) + new_data = table.transform(new_domain) + if impute: + new_data = SklImpute()(new_data) + return new_data + + +# TODO I have put this function here as a substitute the above `_preprocess`. +# None of them really belongs here; (re?)move them, eventually. +def remove_discrete_features(data): + """Remove discrete columns from the data.""" + new_domain = Domain( + [a for a in data.domain.attributes if a.is_continuous], + data.domain.class_vars, + data.domain.metas) + return data.transform(new_domain) + + +def impute(data): + """Impute missing values.""" + return SklImpute()(data) + + +def _orange_to_numpy(x): + """ + Return :class:`numpy.ndarray` (dense or sparse) with attribute data + from the given instance of :class:`Orange.data.Table`, + :class:`Orange.data.RowInstance` or :class:`Orange.data.Instance`. + """ + if isinstance(x, Table): + return x.X + elif isinstance(x, Instance): + return np.atleast_2d(x.x) + elif isinstance(x, np.ndarray): + return np.atleast_2d(x) + else: + return x # e.g. None + + +class Distance: + """ + Base class for construction of distances models (:obj:`DistanceModel`). + + Distances can be computed between all pairs of rows in one table, or + between pairs where one row is from one table and one from another. + + If `axis` is set to `0`, the class computes distances between all pairs + of columns in a table. Distances between columns from separate tables are + probably meaningless, thus unsupported. + + The class can be used as follows: + + - Constructor is called only with keyword argument `axis` that + specifies the axis over which the distances are computed, and with other + subclass-specific keyword arguments. + - Next, we call the method `fit(data)` to produce an instance of + :obj:`DistanceModel`; the instance stores any parameters needed for + computation of distances, such as statistics for normalization and + handling of missing data. + - We can then call the :obj:`DistanceModel` with data to compute the + distance between its rows or columns, or with two data tables to + compute distances between all pairs of rows. + + The second, shorter way to use this class is to call the constructor with + one or two data tables and any additional keyword arguments. Constructor + will execute the above steps and return :obj:`~Orange.misc.DistMatrix`. + Such usage is here for backward compatibility, practicality and efficiency. + + Args: + e1 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or \ + :obj:`np.ndarray` or `None`): + data on which to train the model and compute the distances + e2 (:obj:`~Orange.data.Table` or :obj:`~Orange.data.Instance` or \ + :obj:`np.ndarray` or `None`): + if present, the class computes distances with pairs coming from + the two tables + axis (int): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers. + + Attributes: + axis (int): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers. + + The capabilities of the metrics are described with class attributes. + + If class attribute `supports_discrete` is `True`, the distance + also uses discrete attributes to compute row distances. The use of discrete + attributes depends upon the type of distance; e.g. Jaccard distance observes + whether the value is zero or non-zero, while Euclidean and Manhattan + distance observes whether a pair of values is same or different. + + Class attribute `supports_missing` indicates that the distance can cope + with missing data. In such cases, letting the distance handle it should + be preferred over pre-imputation of missing values. + + Class attribute `supports_normalization` indicates that the constructor + accepts an argument `normalize`. If set to `True`, the metric will attempt + to normalize the values in a sense that each attribute will have equal + influence. For instance, the Euclidean distance subtract the mean and + divides the result by the deviation, while Manhattan distance uses the + median and MAD. + + If class attribute `supports_sparse` is `True`, the class will handle + sparse data. Currently, all classes that do handle it rely on fallbacks to + SKL metrics. These, however, do not support discrete data and missing + values, and will fail silently. + """ + supports_sparse = False + supports_discrete = False + supports_normalization = False + supports_missing = True + + def __new__(cls, e1=None, e2=None, axis=1, impute=False, **kwargs): + self = super().__new__(cls) + self.axis = axis + self.impute = impute + # Ugly, but needed to allow allow setting subclass-specific parameters + # (such as normalize) when `e1` is not `None` and the `__new__` in the + # subclass is skipped + self.__dict__.update(**kwargs) + if e1 is None: + return self + + # Fallbacks for sparse data and numpy tables. Remove when subclasses + # no longer use fallbacks for sparse data, and handling numpy tables + # becomes obsolete (or handled elsewhere) + if (not hasattr(e1, "domain") + or hasattr(e1, "is_sparse") and e1.is_sparse()): + fallback = getattr(self, "fallback", None) + if fallback is not None: + # pylint disable=not-callable + return fallback(e1, e2, axis, impute) + + # Magic constructor + model = self.fit(e1) + return model(e1, e2) + + def fit(self, e1): + """Abstract method returning :obj:`DistanceModel` fit to the data""" + pass + + @staticmethod + def check_no_discrete(n_vals): + """ + Raise an exception if there are any discrete attributes. + + Args: + n_vals (list of int): number of attributes values, 0 for continuous + """ + if any(n_vals): + raise ValueError("columns with discrete values are incommensurable") + + +class DistanceModel: + """ + Base class for classes that compute distances between data rows or columns. + Instances of these classes are not constructed directly but returned by + the corresponding instances of :obj:`Distance`. + + Attributes: + axis (int, readonly): + axis over which the distances are computed, 1 (default) for + rows, 0 for columns + impute (bool): + if `True` (default is `False`), nans in the computed distances + are replaced with zeros, and infs with very large numbers + + """ + def __init__(self, axis, impute=False): + self._axis = axis + self.impute = impute + + @property + def axis(self): + return self._axis + + def __call__(self, e1, e2=None): + """ + If e2 is omitted, calculate distances between all rows (axis=1) or + columns (axis=2) of e1. If e2 is present, calculate distances between + all pairs if rows from e1 and e2. + + This method converts the data into numpy arrays, calls the method + `compute_data` and packs the result into `DistMatrix`. Subclasses are + expected to define the `compute_data` and not the `__call__` method. + + Args: + e1 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): + input data + e2 (Orange.data.Table or Orange.data.Instance or numpy.ndarray): + secondary data + + Returns: + A distance matrix (Orange.misc.distmatrix.DistMatrix) + """ + if self.axis == 0 and e2 is not None: + # Backward compatibility fix + if e2 is e1: + e2 = None + else: + raise ValueError("Two tables cannot be compared by columns") + + x1 = _orange_to_numpy(e1) + x2 = _orange_to_numpy(e2) + dist = self.compute_distances(x1, x2) + if self.impute and np.isnan(dist).any(): + dist = np.nan_to_num(dist) + if isinstance(e1, (Table, RowInstance)): + dist = DistMatrix(dist, e1, e2, self.axis) + else: + dist = DistMatrix(dist) + return dist + + def compute_distances(self, x1, x2): + """ + Abstract method for computation of distances between rows or colums of + `x1`, or between rows of `x1` and `x2`. Do not call directly.""" + pass + + +class FittedDistanceModel(DistanceModel): + """ + Base class for models that store attribute-related data for normalization + and imputation, and that treat discrete and continuous columns separately. + + Attributes: + attributes (list of `Variable`): attributes on which the model was fit + discrete (np.ndarray): bool array indicating discrete attributes + continuous (np.ndarray): bool array indicating continuous attributes + """ + def __init__(self, attributes, axis=1, impute=False): + super().__init__(axis, impute) + self.attributes = attributes + + def __call__(self, e1, e2=None): + if e1.domain.attributes != self.attributes or \ + e2 is not None and e2.domain.attributes != self.attributes: + raise ValueError("mismatching domains") + return super().__call__(e1, e2) + + def continuous_columns(self, x1, x2, offset, scale): + """ + Extract and scale continuous columns from data tables. + If the second table is None, it defaults to the first table. + + Values are scaled if `self.normalize` is `True`. + + Args: + x1 (np.ndarray): first table + x2 (np.ndarray or None): second table + offset (float): a constant (e.g. mean, median) subtracted from data + scale: (float): divider (e.g. deviation) + + Returns: + data1 (np.ndarray): scaled continuous columns from `x1` + data2 (np.ndarray): scaled continuous columns from `x2` or `x1` + """ + if self.continuous.all() and not self.normalize: + data1, data2 = x1, x2 + else: + data1 = x1[:, self.continuous] + if x2 is not None: + data2 = x2[:, self.continuous] + if self.normalize: + data1 = x1[:, self.continuous] + data1 -= offset + data1 /= scale + if x2 is not None: + data2 = x2[:, self.continuous] + data2 -= offset + data2 /= scale + if x2 is None: + data2 = data1 + return data1, data2 + + def discrete_columns(self, x1, x2): + """ + Return discrete columns from the given tables. + If the second table is None, it defaults to the first table. + """ + if self.discrete.all(): + data1, data2 = x1, x1 if x2 is None else x2 + else: + data1 = x1[:, self.discrete] + data2 = data1 if x2 is None else x2[:, self.discrete] + return data1, data2 + + +class FittedDistance(Distance): + """ + Base class for fitting models that store attribute-related data for + normalization and imputation, and that treat discrete and continuous + columns separately. + + The class implements a method `fit` that calls either `fit_columns` + or `fit_rows` with the data and the number of values for discrete + attributes. The provided method `fit_rows` calls methods + `get_discrete_stats` and `get_continuous_stats` that can be implemented + in derived classes. + + Class attribute `rows_model_type` contains the type of the model returned by + `fit_rows`. + """ + rows_model_type = None #: Option[FittedDistanceModel] + + def fit(self, data): + """ + Prepare the data on attributes, call `fit_cols` or `fit_rows` and + return the resulting model. + """ + attributes = data.domain.attributes + x = _orange_to_numpy(data) + n_vals = np.fromiter( + (len(attr.values) if attr.is_discrete else 0 + for attr in attributes), + dtype=np.int32, count=len(attributes)) + return [self.fit_cols, self.fit_rows][self.axis](attributes, x, n_vals) + + def fit_cols(self, attributes, x, n_vals): + """ + Return DistanceModel for computation of distances between columns. + Derived classes must define this method. + + Args: + attributes (list of Orange.data.Variable): list of attributes + x (np.ndarray): data + n_vals (np.ndarray): number of attribute values, 0 for continuous + """ + pass + + def fit_rows(self, attributes, x, n_vals): + """ + Return a DistanceModel for computation of distances between rows. + + The model type is `self.row_distance_model`. It stores the data for + imputation of discrete and continuous values, and for normalization + of continuous values. Typical examples are the Euclidean and Manhattan + distance, for which the following data is stored: + + For continuous columns: + + - offsets[col] is the number subtracted from values in column `col` + - scales[col] is the divisor for values in columns `col` + - dist_missing2_cont[col]: the value used for distance between two + missing values in column `col` + + For discrete values: + + - dist_missing_disc[col, value] is the distance added for the given + `value` in the column `col` if the value for the other row is + missing + - dist_missing2_disc[col]: the distance between two missing values in + column `col` + """ + n_cols = len(n_vals) + + discrete = n_vals > 0 + n_bins = max(n_vals, default=0) + n_discrete = sum(discrete) + dist_missing_disc = np.zeros((n_discrete, n_bins), dtype=float) + dist_missing2_disc = np.zeros(n_discrete, dtype=float) + + continuous = ~discrete + n_continuous = sum(continuous) + offsets = np.zeros(n_continuous, dtype=float) + scales = np.empty(n_continuous, dtype=float) + dist_missing2_cont = np.zeros(n_continuous, dtype=float) + + curr_disc = curr_cont = 0 + for col in range(n_cols): + column = x[:, col] + if np.isnan(column).all(): + continuous[col] = discrete[col] = False + elif discrete[col]: + discrete_stats = self.get_discrete_stats(column, n_bins) + if discrete_stats is not None: + dist_missing_disc[curr_disc], \ + dist_missing2_disc[curr_disc] = discrete_stats + curr_disc += 1 + else: + continuous_stats = self.get_continuous_stats(column) + if continuous_stats is not None: + offsets[curr_cont], scales[curr_cont],\ + dist_missing2_cont[curr_cont] = continuous_stats + curr_cont += 1 + else: + continuous[col] = False + # pylint: disable=not-callable + return self.rows_model_type( + attributes, impute, getattr(self, "normalize", False), + continuous, discrete, + offsets[:curr_cont], scales[:curr_cont], + dist_missing2_cont[:curr_cont], + dist_missing_disc, dist_missing2_disc) + + def get_discrete_stats(self, column, n_bins): + """ + Return tables used computing distance between missing discrete values. + + Args: + column (np.ndarray): column data + n_bins (int): maximal number of bins in the data set + + Returns: + dist_missing_disc (np.ndarray): `dist_missing_disc[value]` is + 1 - probability of `value`, which is used as the distance added + for the given `value` in the column `col` if the value for the + other row is missing + dist_missing2_disc (float): the distance between two missing + values in this columns + """ + dist = util.bincount(column, minlength=n_bins)[0] + dist /= max(1, sum(dist)) + return 1 - dist, 1 - np.sum(dist ** 2) + + def get_continuous_stats(self, column): + """ + Compute statistics for imputation and normalization of continuous data. + Derived classes must define this method. + + Args: + column (np.ndarray): column data + + Returns: + offset (float): the number subtracted from values in column + scales (float): the divisor for values in column + dist_missing2_cont (float): the value used for distance between two + missing values in column + """ + pass + + +# Fallbacks for distances in sparse data +# To be removed as the corresponding functionality is implemented properly + +class SklDistance: + """ + Wrapper for functions sklearn's metrics. Used only as temporary fallbacks + when `Euclidean`, `Manhattan`, `Cosine` or `Jaccard` are given sparse data + or raw numpy arrays. These classes can't handle discrete or missing data + and normalization. Do not use for wrapping new classes. + """ + def __init__(self, metric): + self.metric = metric + + def __call__(self, e1, e2=None, axis=1, impute=False): + x1 = _orange_to_numpy(e1) + x2 = _orange_to_numpy(e2) + if axis == 0: + x1 = x1.T + if x2 is not None: + x2 = x2.T + dist = skl_metrics.pairwise.pairwise_distances( + x1, x2, metric=self.metric) + if impute and np.isnan(dist).any(): + dist = np.nan_to_num(dist) + if isinstance(e1, (Table, RowInstance)): + dist_matrix = DistMatrix(dist, e1, e2, axis) + else: + dist_matrix = DistMatrix(dist) + return dist_matrix diff --git a/Orange/distance/distance.py b/Orange/distance/distance.py new file mode 100644 index 00000000000..f25eae93a6f --- /dev/null +++ b/Orange/distance/distance.py @@ -0,0 +1,529 @@ +import numpy as np +from scipy import stats +import sklearn.metrics as skl_metrics +from sklearn.utils.extmath import row_norms, safe_sparse_dot + +from Orange.distance import _distance +from Orange.statistics import util + +from .base import (Distance, DistanceModel, FittedDistance, FittedDistanceModel, + SklDistance, _orange_to_numpy) + + +class EuclideanRowsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between rows. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ + def __init__(self, attributes, impute, normalize, + continuous, discrete, + means, vars, dist_missing2_cont, + dist_missing_disc, dist_missing2_disc): + super().__init__(attributes, 1, impute) + self.normalize = normalize + self.continuous = continuous + self.discrete = discrete + self.means = means + self.vars = vars + self.dist_missing2_cont = dist_missing2_cont + self.dist_missing_disc = dist_missing_disc + self.dist_missing2_disc = dist_missing2_disc + + def compute_distances(self, x1, x2=None): + """ + The method + - extracts normalized continuous attributes and then uses `row_norms` + and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 + (the trick from sklearn); + - calls a function in Cython that recomputes the distances between pairs + of rows that yielded nan + - calls a function in Cython that adds the contributions of discrete + columns + """ + if self.continuous.any(): + data1, data2 = self.continuous_columns( + x1, x2, self.means, np.sqrt(2 * self.vars)) + + # adapted from sklearn.metric.euclidean_distances + xx = row_norms(data1, squared=True)[:, np.newaxis] + if x2 is not None: + yy = row_norms(data2, squared=True)[np.newaxis, :] + else: + yy = xx.T + distances = safe_sparse_dot(data1, data2.T, dense_output=True) + distances *= -2 + distances += xx + distances += yy + np.maximum(distances, 0, out=distances) + if x2 is None: + distances.flat[::distances.shape[0] + 1] = 0.0 + fixer = _distance.fix_euclidean_rows_normalized if self.normalize \ + else _distance.fix_euclidean_rows + fixer(distances, data1, data2, + self.means, self.vars, self.dist_missing2_cont, + x2 is not None) + else: + distances = np.zeros((x1.shape[0], + (x2 if x2 is not None else x1).shape[0])) + + if np.any(self.discrete): + data1, data2 = self.discrete_columns(x1, x2) + _distance.euclidean_rows_discrete( + distances, data1, data2, self.dist_missing_disc, + self.dist_missing2_disc, x2 is not None) + + return np.sqrt(distances) + + +class EuclideanColumnsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between columns. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ + def __init__(self, attributes, impute, normalize, means, vars): + super().__init__(attributes, 0, impute) + self.normalize = normalize + self.means = means + self.vars = vars + + def compute_distances(self, x1, x2=None): + """ + The method + - extracts normalized continuous attributes and then uses `row_norms` + and `safe_sparse_do`t to compute the distance as x^2 - 2xy - y^2 + (the trick from sklearn); + - calls a function in Cython that adds the contributions of discrete + columns + """ + if self.normalize: + x1 = x1 - self.means + x1 /= np.sqrt(2 * self.vars) + + # adapted from sklearn.metric.euclidean_distances + xx = row_norms(x1.T, squared=True)[:, np.newaxis] + distances = safe_sparse_dot(x1.T, x1, dense_output=True) + distances *= -2 + distances += xx + distances += xx.T + np.maximum(distances, 0, out=distances) + distances.flat[::distances.shape[0] + 1] = 0.0 + + fixer = _distance.fix_euclidean_cols_normalized if self.normalize \ + else _distance.fix_euclidean_cols + fixer(distances, x1, self.means, self.vars) + return np.sqrt(distances) + + +class Euclidean(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + supports_normalization = True + fallback = SklDistance('euclidean') + rows_model_type = EuclideanRowsModel + + def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): + return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) + + def get_continuous_stats(self, column): + """ + Return mean, variance and distance betwwen pairs of missing values + for the given columns. The method is called by inherited `fit_rows` + to construct a row-distance model + """ + mean = util.nanmean(column) + var = util.nanvar(column) + if self.normalize: + if var == 0: + return None + dist_missing2_cont = 1 + else: + dist_missing2_cont = 2 * var + if np.isnan(dist_missing2_cont): + dist_missing2_cont = 0 + return mean, var, dist_missing2_cont + + def fit_cols(self, attributes, x, n_vals): + """ + Return `EuclideanColumnsModel` with stored means and variances + for normalization and imputation. + """ + self.check_no_discrete(n_vals) + means = np.nanmean(x, axis=0) + vars = np.nanvar(x, axis=0) + if self.normalize and (np.isnan(vars).any() or not vars.all()): + raise ValueError("some columns are constant or have no values") + return EuclideanColumnsModel( + attributes, self.impute, self.normalize, means, vars) + + +class ManhattanRowsModel(FittedDistanceModel): + """ + Model for computation of Euclidean distances between rows. + + Means are used as offsets for normalization, and two deviations are + used for scaling. + """ + def __init__(self, attributes, impute, normalize, + continuous, discrete, + medians, mads, dist_missing2_cont, + dist_missing_disc, dist_missing2_disc): + super().__init__(attributes, 1, impute) + self.normalize = normalize + self.continuous = continuous + self.discrete = discrete + self.medians = medians + self.mads = mads + self.dist_missing2_cont = dist_missing2_cont + self.dist_missing_disc = dist_missing_disc + self.dist_missing2_disc = dist_missing2_disc + + def compute_distances(self, x1, x2): + """ + The method + - extracts normalized continuous attributes and computes distances + ignoring the possibility of nans + - recomputes the distances between pairs of rows that yielded nans + - adds the contributions of discrete columns using the same function as + the Euclidean distance + """ + if self.continuous.any(): + data1, data2 = self.continuous_columns( + x1, x2, self.medians, 2 * self.mads) + distances = _distance.manhattan_rows_cont( + data1, data2, x2 is not None) + if self.normalize: + _distance.fix_manhattan_rows_normalized( + distances, data1, data2, x2 is not None) + else: + _distance.fix_manhattan_rows( + distances, data1, data2, + self.medians, self.mads, self.dist_missing2_cont, + x2 is not None) + else: + distances = np.zeros((x1.shape[0], + (x2 if x2 is not None else x1).shape[0])) + + if np.any(self.discrete): + data1, data2 = self.discrete_columns(x1, x2) + # For discrete attributes, Euclidean is same as Manhattan + _distance.euclidean_rows_discrete( + distances, data1, data2, self.dist_missing_disc, + self.dist_missing2_disc, x2 is not None) + + return distances + + +class ManhattanColumnsModel(FittedDistanceModel): + """ + Model for computation of Manhattan distances between columns. + + Medians are used as offsets for normalization, and two MADS are + used for scaling. + """ + + def __init__(self, attributes, impute, normalize, medians, mads): + super().__init__(attributes, 0, impute) + self.normalize = normalize + self.medians = medians + self.mads = mads + + def compute_distances(self, x1, x2=None): + if self.normalize: + x1 = x1 - self.medians + x1 /= 2 + x1 /= self.mads + return _distance.manhattan_cols(x1, self.medians, self.mads, self.normalize) + + +class Manhattan(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + supports_normalization = True + fallback = SklDistance('manhattan') + rows_model_type = ManhattanRowsModel + + def __new__(cls, e1=None, e2=None, axis=1, impute=False, normalize=False): + return super().__new__(cls, e1, e2, axis, impute, normalize=normalize) + + def get_continuous_stats(self, column): + """ + Return median, MAD and distance betwwen pairs of missing values + for the given columns. The method is called by inherited `fit_rows` + to construct a row-distance model + """ + median = np.nanmedian(column) + mad = np.nanmedian(np.abs(column - median)) + if self.normalize: + if mad == 0: + return None + dist_missing2_cont = 1 + else: + dist_missing2_cont = 2 * mad + if np.isnan(dist_missing2_cont): + dist_missing2_cont = 0 + return median, mad, dist_missing2_cont + + def fit_cols(self, attributes, x, n_vals): + """ + Return `ManhattanColumnsModel` with stored medians and MADs + for normalization and imputation. + """ + self.check_no_discrete(n_vals) + medians = np.nanmedian(x, axis=0) + mads = np.nanmedian(np.abs(x - medians), axis=0) + if self.normalize and (np.isnan(mads).any() or not mads.all()): + raise ValueError( + "some columns have zero absolute distance from median, " + "or no values") + return ManhattanColumnsModel( + attributes, self.impute, self.normalize, medians, mads) + + +class Cosine(FittedDistance): + supports_sparse = True # via fallback + supports_discrete = True + fallback = SklDistance('cosine') + + @staticmethod + def discrete_to_indicators(x, discrete): + """Change non-zero values of discrete attributes to 1.""" + if discrete.any(): + x = x.copy() + for col, disc in enumerate(discrete): + if disc: + x[:, col].clip(0, 1, out=x[:, col]) + return x + + def fit_rows(self, attributes, x, n_vals): + """Return a model for cosine distances with stored means for imputation + """ + discrete = n_vals > 0 + x = self.discrete_to_indicators(x, discrete) + means = util.nanmean(x, axis=0) + means = np.nan_to_num(means) + return self.CosineModel(attributes, self.axis, self.impute, + discrete, means) + + fit_cols = fit_rows + + class CosineModel(FittedDistanceModel): + """Model for computation of cosine distances across rows and columns. + All non-zero discrete values are treated as 1.""" + def __init__(self, attributes, axis, impute, discrete, means): + super().__init__(attributes, axis, impute) + self.discrete = discrete + self.means = means + + def compute_distances(self, x1, x2): + """ + The method imputes the missing values as means and calls + safe_sparse_dot. Imputation simplifies computation at a cost of + (theoretically) slightly wrong distance between pairs of missing + values. + """ + + def prepare_data(x): + if self.discrete.any(): + data = Cosine.discrete_to_indicators(x, self.discrete) + else: + data = x.copy() + for col, mean in enumerate(self.means): + column = data[:, col] + column[np.isnan(column)] = mean + if self.axis == 0: + data = data.T + data /= row_norms(data)[:, np.newaxis] + return data + + data1 = prepare_data(x1) + data2 = data1 if x2 is None else prepare_data(x2) + dist = safe_sparse_dot(data1, data2.T) + np.clip(dist, 0, 1, out=dist) + if x2 is None: + dist.flat[::dist.shape[0] + 1] = 1.0 + return 1 - dist + + +class JaccardModel(FittedDistanceModel): + """ + Model for computation of cosine distances across rows and columns. + All non-zero values are treated as 1. + """ + def __init__(self, attributes, axis, impute, ps): + super().__init__(attributes, axis, impute) + self.ps = ps + + def compute_distances(self, x1, x2): + """ + The method uses a function implemented in Cython. Data (`x1` and `x2`) + is accompanied by two tables. One is a 2-d table in which elements of + `x1` (`x2`) are replaced by 0's and 1's. The other is a vector + indicating rows (or column) with nan values. + + The function in Cython uses a fast loop without any conditions to + compute distances between rows without missing values, and a slower + loop for those with missing values. + """ + nonzeros1 = np.not_equal(x1, 0).view(np.int8) + if self.axis == 1: + nans1 = _distance.any_nan_row(x1) + if x2 is None: + nonzeros2, nans2 = nonzeros1, nans1 + else: + nonzeros2 = np.not_equal(x2, 0).view(np.int8) + nans2 = _distance.any_nan_row(x2) + return _distance.jaccard_rows( + nonzeros1, nonzeros2, + x1, x1 if x2 is None else x2, + nans1, nans2, + self.ps, + x2 is not None) + else: + nans1 = _distance.any_nan_row(x1.T) + return _distance.jaccard_cols( + nonzeros1, x1, nans1, self.ps) + + +class Jaccard(FittedDistance): + supports_sparse = False + supports_discrete = True + fallback = SklDistance('jaccard') + ModelType = JaccardModel + + def fit_rows(self, attributes, x, n_vals): + """ + Return a model for computation of Jaccard values. The model stores + frequencies of non-zero values per each column. + """ + ps = np.fromiter( + (_distance.p_nonzero(x[:, col]) for col in range(len(n_vals))), + dtype=np.double, count=len(n_vals)) + return JaccardModel(attributes, self.axis, self.impute, ps) + + fit_cols = fit_rows + + +class CorrelationDistanceModel(DistanceModel): + """Helper class for normal and absolute Pearson and Spearman correlation""" + def __init__(self, absolute, axis=1, impute=False): + super().__init__(axis, impute) + self.absolute = absolute + + def compute_distances(self, x1, x2): + if x2 is None: + x2 = x1 + rho = self.compute_correlation(x1, x2) + if self.absolute: + return (1. - np.abs(rho)) / 2. + else: + return (1. - rho) / 2. + + def compute_correlation(self, x1, x2): + pass + + +class SpearmanModel(CorrelationDistanceModel): + def compute_correlation(self, x1, x2): + rho = stats.spearmanr(x1, x2, axis=self.axis)[0] + if isinstance(rho, np.float): + return np.array([[rho]]) + slc = x1.shape[1 - self.axis] + return rho[:slc, slc:] + + +class CorrelationDistance(Distance): + supports_missing = False + + +class SpearmanR(CorrelationDistance): + def fit(self, _): + return SpearmanModel(False, self.axis, self.impute) + + +class SpearmanRAbsolute(CorrelationDistance): + def fit(self, _): + return SpearmanModel(True, self.axis, self.impute) + + +class PearsonModel(CorrelationDistanceModel): + def compute_correlation(self, x1, x2): + if self.axis == 0: + x1 = x1.T + x2 = x2.T + return np.array([[stats.pearsonr(i, j)[0] for j in x2] for i in x1]) + + +class PearsonR(CorrelationDistance): + def fit(self, _): + return PearsonModel(False, self.axis, self.impute) + + +class PearsonRAbsolute(CorrelationDistance): + def fit(self, _): + return PearsonModel(True, self.axis, self.impute) + + +class Mahalanobis(Distance): + supports_sparse = False + supports_missing = False + + def fit(self, data): + """Return a model with stored inverse covariance matrix""" + x = _orange_to_numpy(data) + if self.axis == 0: + x = x.T + try: + c = np.cov(x.T) + except: + raise MemoryError("Covariance matrix is too large.") + try: + vi = np.linalg.inv(c) + except: + raise ValueError("Computation of inverse covariance matrix failed.") + return MahalanobisModel(self.axis, self.impute, vi) + + +class MahalanobisModel(DistanceModel): + def __init__(self, axis, impute, vi): + super().__init__(axis, impute) + self.vi = vi + + def __call__(self, e1, e2=None, impute=None): + # argument `impute` is here just for backward compatibility; don't use + if impute is not None: + self.impute = impute + return super().__call__(e1, e2) + + def compute_distances(self, x1, x2): + if self.axis == 0: + x1 = x1.T + if x2 is not None: + x2 = x2.T + if x1.shape[1] != self.vi.shape[0] or \ + x2 is not None and x2.shape[1] != self.vi.shape[0]: + raise ValueError('Incorrect number of features.') + return skl_metrics.pairwise.pairwise_distances( + x1, x2, metric='mahalanobis', VI=self.vi) + + +# TODO: Appears to have been used only in the Distances widget (where it had +# to be handled as a special case and is now replaced with the above class) +# and in tests. Remove? +class MahalanobisDistance: + """ + Obsolete class needed for backward compatibility. + + Previous implementation of instances did not have a separate fitting phase, + except for MahalanobisDistance, which was implemented in a single class + but required first (explicitly) calling the method 'fit'. The backward + compatibility hack in :obj:`Distance` cannot handle such use, hence it + is provided in this class. + """ + def __new__(cls, data=None, axis=1, _='Mahalanobis'): + if data is None: + return cls + return Mahalanobis(axis=axis).fit(data) diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index 019f831abbb..3697f7ad401 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -637,6 +637,8 @@ def test_pearsonrabsolute_distance_numpy(self): [0.42682613]])) +# Pylint doesn't get magic __new__ operators +# pylint: disable=not-callable class TestMahalanobis(TestCase): def setUp(self): self.n, self.m = 10, 5 From 890c5e1f0981c29463699105bcdbc0e31d9983fe Mon Sep 17 00:00:00 2001 From: janezd Date: Sat, 22 Jul 2017 11:05:03 +0200 Subject: [PATCH 25/27] distances: Reformat old test_distances.py --- Orange/tests/test_distances.py | 917 ++++++++++++++++++++------------- 1 file changed, 555 insertions(+), 362 deletions(-) diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index 3697f7ad401..46693b2aafc 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -30,6 +30,7 @@ def setUpClass(cls): cls.iris = Table('iris') cls.dist = Euclidean(cls.iris) + # pylint: disable=unsubscriptable-object def test_submatrix(self): sub = self.dist.submatrix([2, 3, 4]) np.testing.assert_equal(sub, self.dist[2:5, 2:5]) @@ -38,8 +39,10 @@ def test_submatrix(self): def test_pickling(self): unpickled_dist = pickle.loads(pickle.dumps(self.dist)) np.testing.assert_equal(unpickled_dist, self.dist) - self.assertTrue(tables_equal(unpickled_dist.row_items, self.dist.row_items)) - self.assertTrue(tables_equal(unpickled_dist.col_items, self.dist.col_items)) + self.assertTrue(tables_equal(unpickled_dist.row_items, + self.dist.row_items)) + self.assertTrue(tables_equal(unpickled_dist.col_items, + self.dist.col_items)) self.assertEqual(unpickled_dist.axis, self.dist.axis) def test_deprecated(self): @@ -181,6 +184,7 @@ def test_save(self): self.assertEqual(m.axis, 0) +# noinspection PyTypeChecker class TestEuclidean(TestCase): @classmethod def setUpClass(cls): @@ -189,60 +193,83 @@ def setUpClass(cls): cls.dist = Euclidean def test_euclidean_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1]), np.array([[0.53851648071346281]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1], axis=1), np.array([[0.53851648071346281]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1]), + np.array([[0.53851648071346281]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1], axis=1), + np.array([[0.53851648071346281]])) def test_euclidean_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.iris[:2]), - np.array([[0., 0.53851648], - [0.53851648, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], axis=0), - np.array([[0., 2.48394847, 5.09313263, 6.78969808], - [2.48394847, 0., 2.64007576, 4.327817], - [5.09313263, 2.64007576, 0., 1.69705627], - [6.78969808, 4.327817, 1.69705627, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[2], self.iris[:3]), - np. array([[0.50990195, 0.3, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[3]), - np.array([[0.64807407], - [0.33166248]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), - np.array([[0., 0.53851648, 0.50990195], - [0.53851648, 0., 0.3]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2]), + np.array([[0., 0.53851648], + [0.53851648, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], axis=0), + np.array([[0., 2.48394847, 5.09313263, 6.78969808], + [2.48394847, 0., 2.64007576, 4.327817], + [5.09313263, 2.64007576, 0., 1.69705627], + [6.78969808, 4.327817, 1.69705627, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2], self.iris[:3]), + np. array([[0.50990195, 0.3, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[3]), + np.array([[0.64807407], + [0.33166248]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[:3]), + np.array([[0., 0.53851648, 0.50990195], + [0.53851648, 0., 0.3]])) def test_euclidean_distance_sparse(self): - np.testing.assert_almost_equal(self.dist(self.sparse), - np.array([[0., 3.74165739, 6.164414], - [3.74165739, 0., 4.47213595], - [6.164414, 4.47213595, 0.]])) - np.testing.assert_almost_equal(self.dist(self.sparse, axis=0), - np.array([[0., 4.12310563, 3.31662479], - [4.12310563, 0., 6.164414], - [3.31662479, 6.164414, 0.]])) - np.testing.assert_almost_equal(self.dist(self.sparse[:2]), - np.array([[0., 3.74165739], - [3.74165739, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse), + np.array([[0., 3.74165739, 6.164414], + [3.74165739, 0., 4.47213595], + [6.164414, 4.47213595, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse, axis=0), + np.array([[0., 4.12310563, 3.31662479], + [4.12310563, 0., 6.164414], + [3.31662479, 6.164414, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse[:2]), + np.array([[0., 3.74165739], + [3.74165739, 0.]])) def test_euclidean_distance_numpy(self): - #np.testing.assert_almost_equal(self.dist(self.iris[0].x, self.iris[1].x, axis=1), - # np.array([[0.53851648071346281]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X), - np.array([[0., 0.53851648], - [0.53851648, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[2].x, self.iris[:3].X), - np. array([[0.50990195, 0.3, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[3].x), - np.array([[0.64807407], - [0.33166248]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[:3].X), - np.array([[0., 0.53851648, 0.50990195], - [0.53851648, 0., 0.3]])) - - + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X), + np.array([[0., 0.53851648], + [0.53851648, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2].x, self.iris[:3].X), + np. array([[0.50990195, 0.3, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[3].x), + np.array([[0.64807407], + [0.33166248]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[:3].X), + np.array([[0., 0.53851648, 0.50990195], + [0.53851648, 0., 0.3]])) + + +# noinspection PyTypeChecker class TestManhattan(TestCase): @classmethod def setUpClass(cls): @@ -251,59 +278,86 @@ def setUpClass(cls): cls.dist = Manhattan def test_manhattan_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1]), np.array([[0.7]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1], axis=1), np.array([[0.7]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1]), + np.array([[0.7]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1], axis=1), + np.array([[0.7]])) def test_manhattan_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.iris[:2]), - np.array([[0., 0.7], - [0.7, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], axis=0), - np.array([[0., 3.5, 7.2, 9.6], - [3.5, 0., 3.7, 6.1], - [7.2, 3.7, 0., 2.4], - [9.6, 6.1, 2.4, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[2], self.iris[:3]), - np.array([[0.8, 0.5, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[3]), - np.array([[1.], - [0.5]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), - np.array([[0., 0.7, 0.8], - [0.7, 0., 0.5]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2]), + np.array([[0., 0.7], + [0.7, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], axis=0), + np.array([[0., 3.5, 7.2, 9.6], + [3.5, 0., 3.7, 6.1], + [7.2, 3.7, 0., 2.4], + [9.6, 6.1, 2.4, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2], self.iris[:3]), + np.array([[0.8, 0.5, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[3]), + np.array([[1.], + [0.5]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[:3]), + np.array([[0., 0.7, 0.8], + [0.7, 0., 0.5]])) def test_manhattan_distance_sparse(self): - np.testing.assert_almost_equal(self.dist(self.sparse), - np.array([[0., 6., 10.], - [6., 0., 6.], - [10., 6., 0.]])) - np.testing.assert_almost_equal(self.dist(self.sparse, axis=0), - np.array([[0., 5., 5.], - [5., 0., 10.], - [5., 10., 0.]])) - np.testing.assert_almost_equal(self.dist(self.sparse[:2]), - np.array([[0., 6.], - [6., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse), + np.array([[0., 6., 10.], + [6., 0., 6.], + [10., 6., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse, axis=0), + np.array([[0., 5., 5.], + [5., 0., 10.], + [5., 10., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.sparse[:2]), + np.array([[0., 6.], + [6., 0.]])) def test_manhattan_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.iris[0].x, self.iris[1].x, axis=1), np.array([[0.7]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X), - np.array([[0., 0.7], - [0.7, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[2].x, self.iris[:3].X), - np.array([[0.8, 0.5, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[3].x), - np.array([[1.], - [0.5]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[:3].X), - np.array([[0., 0.7, 0.8], - [0.7, 0., 0.5]])) - - + np.testing.assert_almost_equal( + self.dist(self.iris[0].x, self.iris[1].x, axis=1), + np.array([[0.7]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X), + np.array([[0., 0.7], + [0.7, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2].x, self.iris[:3].X), + np.array([[0.8, 0.5, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[3].x), + np.array([[1.], + [0.5]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[:3].X), + np.array([[0., 0.7, 0.8], + [0.7, 0., 0.5]])) + + +# noinspection PyTypeChecker class TestCosine(TestCase): @classmethod def setUpClass(cls): @@ -312,59 +366,85 @@ def setUpClass(cls): cls.dist = Cosine def test_cosine_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1]), np.array([[0.00142084]])) - np.testing.assert_almost_equal(self.dist(self.iris[0], self.iris[1], axis=1), np.array([[0.00142084]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0]), np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1]), + np.array([[0.00142084]])) + np.testing.assert_almost_equal( + self.dist(self.iris[0], self.iris[1], axis=1), + np.array([[0.00142084]])) def test_cosine_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.iris[:2]), - np.array([[0., 1.42083650e-03], - [1.42083650e-03, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], axis=0), - np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04], - [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03], - [1.99940020e-04, 2.94551450e-03, 0.0, 0.0], - [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]])) - np.testing.assert_almost_equal(self.dist(self.iris[2], self.iris[:3]), - np.array([[1.26527175e-05, 1.20854727e-03, 0.0]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[3]), - np.array([[0.00089939], - [0.00120607]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2], self.iris[:3]), - np.array([[0.0, 1.42083650e-03, 1.26527175e-05], - [1.42083650e-03, 0.0, 1.20854727e-03]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2]), + np.array([[0., 1.42083650e-03], + [1.42083650e-03, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], axis=0), + np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04], + [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03], + [1.99940020e-04, 2.94551450e-03, 0.0, 0.0], + [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2], self.iris[:3]), + np.array([[1.26527175e-05, 1.20854727e-03, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[3]), + np.array([[0.00089939], + [0.00120607]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2], self.iris[:3]), + np.array([[0.0, 1.42083650e-03, 1.26527175e-05], + [1.42083650e-03, 0.0, 1.20854727e-03]])) def test_cosine_distance_sparse(self): - np.testing.assert_almost_equal(self.dist(self.sparse), - np.array([[0.0, 1.00000000e+00, 7.20627882e-01], - [1.00000000e+00, 0.0, 2.19131191e-01], - [7.20627882e-01, 2.19131191e-01, 0.0]])) - np.testing.assert_almost_equal(self.dist(self.sparse, axis=0), - np.array([[0.0, 7.57464375e-01, 1.68109669e-01], - [7.57464375e-01, 0.0, 1.00000000e+00], - [1.68109669e-01, 1.00000000e+00, 0.0]])) - np.testing.assert_almost_equal(self.dist(self.sparse[:2]), - np.array([[0.0, 1.00000000e+00], - [1.00000000e+00, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.sparse), + np.array([[0.0, 1.00000000e+00, 7.20627882e-01], + [1.00000000e+00, 0.0, 2.19131191e-01], + [7.20627882e-01, 2.19131191e-01, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.sparse, axis=0), + np.array([[0.0, 7.57464375e-01, 1.68109669e-01], + [7.57464375e-01, 0.0, 1.00000000e+00], + [1.68109669e-01, 1.00000000e+00, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.sparse[:2]), + np.array([[0.0, 1.00000000e+00], + [1.00000000e+00, 0.0]])) def test_cosine_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.iris[0].x, self.iris[1].x, axis=1), np.array([[0.00142084]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X), - np.array([[0., 1.42083650e-03], - [1.42083650e-03, 0.]])) - np.testing.assert_almost_equal(self.dist(self.iris[2].x, self.iris[:3].X), - np.array([[1.26527175e-05, 1.20854727e-03, 0.0]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[3].x), - np.array([[0.00089939], - [0.00120607]])) - np.testing.assert_almost_equal(self.dist(self.iris[:2].X, self.iris[:3].X), - np.array([[0.0, 1.42083650e-03, 1.26527175e-05], - [1.42083650e-03, 0.0, 1.20854727e-03]])) - - + np.testing.assert_almost_equal( + self.dist(self.iris[0].x, self.iris[1].x, axis=1), + np.array([[0.00142084]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X), + np.array([[0., 1.42083650e-03], + [1.42083650e-03, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.iris[2].x, self.iris[:3].X), + np.array([[1.26527175e-05, 1.20854727e-03, 0.0]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[3].x), + np.array([[0.00089939], + [0.00120607]])) + np.testing.assert_almost_equal( + self.dist(self.iris[:2].X, self.iris[:3].X), + np.array([[0.0, 1.42083650e-03, 1.26527175e-05], + [1.42083650e-03, 0.0, 1.20854727e-03]])) + + +# noinspection PyTypeChecker class TestJaccard(TestCase): @classmethod def setUpClass(cls): @@ -372,49 +452,73 @@ def setUpClass(cls): cls.dist = Jaccard def test_jaccard_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.titanic[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.titanic[0], self.titanic[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.titanic[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.titanic[0], self.titanic[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.titanic[0], self.titanic[2]), np.array([[0.5]])) - np.testing.assert_almost_equal(self.dist(self.titanic[0], self.titanic[2], axis=1), np.array([[0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0], self.titanic[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0], self.titanic[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0], self.titanic[2]), + np.array([[0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[0], self.titanic[2], axis=1), + np.array([[0.5]])) def test_jaccard_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.titanic), - np.array([[0., 0., 0.5, 0.5], - [0., 0., 0.5, 0.5], - [0.5, 0.5, 0., 0.], - [0.5, 0.5, 0., 0.]])) - np.testing.assert_almost_equal(self.dist(self.titanic, axis=0), - np.array([[0., 1., 0.5], - [1., 0., 1.], - [0.5, 1., 0.]])) - np.testing.assert_almost_equal(self.dist(self.titanic[2], self.titanic[:3]), - np.array([[0.5, 0.5, 0.]])) - np.testing.assert_almost_equal(self.dist(self.titanic[:2], self.titanic[3]), - np.array([[0.5], - [0.5]])) - np.testing.assert_almost_equal(self.dist(self.titanic[:2], self.titanic[:3]), - np.array([[0., 0., 0.5], - [0., 0., 0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic), + np.array([[0., 0., 0.5, 0.5], + [0., 0., 0.5, 0.5], + [0.5, 0.5, 0., 0.], + [0.5, 0.5, 0., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.titanic, axis=0), + np.array([[0., 1., 0.5], + [1., 0., 1.], + [0.5, 1., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[2], self.titanic[:3]), + np.array([[0.5, 0.5, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[:2], self.titanic[3]), + np.array([[0.5], + [0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[:2], self.titanic[:3]), + np.array([[0., 0., 0.5], + [0., 0., 0.5]])) def test_jaccard_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.titanic[0].x, self.titanic[2].x, axis=1), np.array([[0.5]])) - np.testing.assert_almost_equal(self.dist(self.titanic.X), - np.array([[0., 0., 0.5, 0.5], - [0., 0., 0.5, 0.5], - [0.5, 0.5, 0., 0.], - [0.5, 0.5, 0., 0.]])) - np.testing.assert_almost_equal(self.dist(self.titanic[2].x, self.titanic[:3].X), - np.array([[0.5, 0.5, 0.]])) - np.testing.assert_almost_equal(self.dist(self.titanic[:2].X, self.titanic[3].x), - np.array([[0.5], - [0.5]])) - np.testing.assert_almost_equal(self.dist(self.titanic[:2].X, self.titanic[:3].X), - np.array([[0., 0., 0.5], - [0., 0., 0.5]])) - - + np.testing.assert_almost_equal( + self.dist(self.titanic[0].x, self.titanic[2].x, axis=1), + np.array([[0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic.X), + np.array([[0., 0., 0.5, 0.5], + [0., 0., 0.5, 0.5], + [0.5, 0.5, 0., 0.], + [0.5, 0.5, 0., 0.]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[2].x, self.titanic[:3].X), + np.array([[0.5, 0.5, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[:2].X, self.titanic[3].x), + np.array([[0.5], + [0.5]])) + np.testing.assert_almost_equal( + self.dist(self.titanic[:2].X, self.titanic[:3].X), + np.array([[0., 0., 0.5], + [0., 0., 0.5]])) + + +# noinspection PyTypeChecker class TestSpearmanR(TestCase): @classmethod def setUpClass(cls): @@ -422,58 +526,80 @@ def setUpClass(cls): cls.dist = SpearmanR def test_spearmanr_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1]), np.array([[0.5083333333333333]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1], axis=1), - np.array([[0.5083333333333333]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1]), + np.array([[0.5083333333333333]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1], axis=1), + np.array([[0.5083333333333333]])) def test_spearmanr_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.breast[:2]), - np.array([[0., 0.5083333333333333], - [0.5083333333333333, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:4]), - np.array([[0., 0.50833333, 0.075, 0.61666667], - [0.50833333, 0., 0.38333333, 0.53333333], - [0.075, 0.38333333, 0., 0.63333333], - [0.61666667, 0.53333333, 0.63333333, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], - [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:4]), - np.array([[0., 0.50833333, 0.075, 0.61666667], - [0.50833333, 0., 0.38333333, 0.53333333], - [0.075, 0.38333333, 0., 0.63333333]])) - np.testing.assert_almost_equal(self.dist(self.breast[2], self.breast[:3]), - np. array([[0.075, 0.3833333, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[2]), - np. array([[0.075], - [0.3833333], - [0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2]), + np.array([[0., 0.5083333333333333], + [0.5083333333333333, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:4]), + np.array([[0., 0.50833333, 0.075, 0.61666667], + [0.50833333, 0., 0.38333333, 0.53333333], + [0.075, 0.38333333, 0., 0.63333333], + [0.61666667, 0.53333333, 0.63333333, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], axis=0), + np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], + [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], + [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75], + [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[:4]), + np.array([[0., 0.50833333, 0.075, 0.61666667], + [0.50833333, 0., 0.38333333, 0.53333333], + [0.075, 0.38333333, 0., 0.63333333]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2], self.breast[:3]), + np.array([[0.075, 0.3833333, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[2]), + np.array([[0.075], + [0.3833333], + [0.]])) def test_spearmanr_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), - np.array([[0.5083333333333333]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2].X), - np.array([[0., 0.5083333333333333], - [0.5083333333333333, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[2].x, self.breast[:3].X), - np. array([[0.075, 0.3833333, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3].X, self.breast[2].x), - np. array([[0.075], - [0.3833333], - [0.]])) - - + np.testing.assert_almost_equal( + self.dist(self.breast[0].x, self.breast[1].x, axis=1), + np.array([[0.5083333333333333]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2].X), + np.array([[0., 0.5083333333333333], + [0.5083333333333333, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2].x, self.breast[:3].X), + np.array([[0.075, 0.3833333, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3].X, self.breast[2].x), + np.array([[0.075], + [0.3833333], + [0.]])) + + +# noinspection PyTypeChecker class TestSpearmanRAbsolute(TestCase): @classmethod def setUpClass(cls): @@ -481,56 +607,76 @@ def setUpClass(cls): cls.dist = SpearmanRAbsolute def test_spearmanrabsolute_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1]), - np.array([[0.49166666666666664]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1], axis=1), - np.array([[0.49166666666666664]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1]), + np.array([[0.49166666666666664]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1], axis=1), + np.array([[0.49166666666666664]])) def test_spearmanrabsolute_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.breast[:2]), - np.array([[0., 0.49166667], - [0.49166667, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], axis=0), - np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.], - [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], - [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:4]), - np.array([[0., 0.49166667, 0.075, 0.38333333], - [0.49166667, 0., 0.38333333, 0.46666667], - [0.075, 0.38333333, 0., 0.36666667]])) - np.testing.assert_almost_equal(self.dist(self.breast[3], self.breast[:4]), - np.array([[0.3833333, 0.4666667, 0.3666667, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:4], self.breast[3]), - np.array([[0.3833333], - [0.4666667], - [0.3666667], - [0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2]), + np.array([[0., 0.49166667], + [0.49166667, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], axis=0), + np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], + [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], + [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.], + [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25], + [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[:4]), + np.array([[0., 0.49166667, 0.075, 0.38333333], + [0.49166667, 0., 0.38333333, 0.46666667], + [0.075, 0.38333333, 0., 0.36666667]])) + np.testing.assert_almost_equal( + self.dist(self.breast[3], self.breast[:4]), + np.array([[0.3833333, 0.4666667, 0.3666667, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:4], self.breast[3]), + np.array([[0.3833333], + [0.4666667], + [0.3666667], + [0.]])) def test_spearmanrabsolute_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), - np.array([[0.49166666666666664]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2].X), - np.array([[0., 0.49166667], - [0.49166667, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[3].x, self.breast[:4].X), - np.array([[0.3833333, 0.4666667, 0.3666667, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:4].X, self.breast[3].x), - np.array([[0.3833333], - [0.4666667], - [0.3666667], - [0.]])) - - + np.testing.assert_almost_equal( + self.dist(self.breast[0].x, self.breast[1].x, axis=1), + np.array([[0.49166666666666664]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2].X), + np.array([[0., 0.49166667], + [0.49166667, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[3].x, self.breast[:4].X), + np.array([[0.3833333, 0.4666667, 0.3666667, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:4].X, self.breast[3].x), + np.array([[0.3833333], + [0.4666667], + [0.3666667], + [0.]])) + + +# noinspection PyTypeChecker class TestPearsonR(TestCase): @classmethod def setUpClass(cls): @@ -538,53 +684,76 @@ def setUpClass(cls): cls.dist = PearsonR def test_pearsonr_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1]), np.array([[0.48462293898088876]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1], axis=1), - np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1]), + np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1], axis=1), + np.array([[0.48462293898088876]])) def test_pearsonr_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.breast[:2]), - np.array([[0., 0.48462294], - [0.48462294, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20], axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:4]), - np.array([[0., 0.48462294, 0.10133593, 0.5016744], - [0.48462294, 0., 0.32783865, 0.57317387], - [0.10133593, 0.32783865, 0., 0.63789635]])) - np.testing.assert_almost_equal(self.dist(self.breast[2], self.breast[:3]), - np.array([[0.10133593, 0.32783865, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[2]), - np.array([[0.10133593], - [0.32783865], - [0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2]), + np.array([[0., 0.48462294], + [0.48462294, 0.]])) + # pylint: disable=line-too-long + # Because it looks better + np.testing.assert_almost_equal( + self.dist(self.breast[:20], axis=0), + np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], + [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], + [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], + [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], + [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], + [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], + [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119], + [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], + [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[:4]), + np.array([[0., 0.48462294, 0.10133593, 0.5016744], + [0.48462294, 0., 0.32783865, 0.57317387], + [0.10133593, 0.32783865, 0., 0.63789635]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2], self.breast[:3]), + np.array([[0.10133593, 0.32783865, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[2]), + np.array([[0.10133593], + [0.32783865], + [0.]])) def test_pearsonr_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), - np.array([[0.48462293898088876]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2].X), - np.array([[0., 0.48462294], - [0.48462294, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[2].x, self.breast[:3].X), - np.array([[0.10133593, 0.32783865, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3].X, self.breast[2].x), - np.array([[0.10133593], - [0.32783865], - [0.]])) - - + np.testing.assert_almost_equal( + self.dist(self.breast[0].x, self.breast[1].x, axis=1), + np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2].X), + np.array([[0., 0.48462294], + [0.48462294, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2].x, self.breast[:3].X), + np.array([[0.10133593, 0.32783865, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3].X, self.breast[2].x), + np.array([[0.10133593], + [0.32783865], + [0.]])) + + +# noinspection PyTypeChecker class TestPearsonRAbsolute(TestCase): @classmethod def setUpClass(cls): @@ -592,51 +761,74 @@ def setUpClass(cls): cls.dist = PearsonRAbsolute def test_pearsonrabsolute_distance_one_example(self): - np.testing.assert_almost_equal(self.dist(self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0]), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[0], axis=1), np.array([[0]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1]), np.array([[0.48462293898088876]])) - np.testing.assert_almost_equal(self.dist(self.breast[0], self.breast[1], axis=1), - np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0]), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[0], axis=1), + np.array([[0]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1]), + np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[0], self.breast[1], axis=1), + np.array([[0.48462293898088876]])) def test_pearsonrabsolute_distance_many_examples(self): - np.testing.assert_almost_equal(self.dist(self.breast[:2]), - np.array([[0., 0.48462294], - [0.48462294, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:20], axis=0), - np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], - [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], - [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], - [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], - [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], - [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], - [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881], - [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], - [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:3], self.breast[:4]), - np.array([[0., 0.48462294, 0.10133593, 0.4983256], - [0.48462294, 0., 0.32783865, 0.42682613], - [0.10133593, 0.32783865, 0., 0.36210365]])) - np.testing.assert_almost_equal(self.dist(self.breast[2], self.breast[:3]), - np.array([[0.10133593, 0.32783865, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2], self.breast[3]), - np.array([[0.4983256], - [0.42682613]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2]), + np.array([[0., 0.48462294], + [0.48462294, 0.]])) + # pylint: disable=line-too-long + # Because it looks better + np.testing.assert_almost_equal( + self.dist(self.breast[:20], axis=0), + np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752], + [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547], + [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168], + [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826], + [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252], + [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076], + [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881], + [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368], + [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:3], self.breast[:4]), + np.array([[0., 0.48462294, 0.10133593, 0.4983256], + [0.48462294, 0., 0.32783865, 0.42682613], + [0.10133593, 0.32783865, 0., 0.36210365]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2], self.breast[:3]), + np.array([[0.10133593, 0.32783865, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2], self.breast[3]), + np.array([[0.4983256], + [0.42682613]])) def test_pearsonrabsolute_distance_numpy(self): - np.testing.assert_almost_equal(self.dist(self.breast[0].x, self.breast[1].x, axis=1), - np.array([[0.48462293898088876]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2].X), - np.array([[0., 0.48462294], - [0.48462294, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[2].x, self.breast[:3].X), - np.array([[0.10133593, 0.32783865, 0.]])) - np.testing.assert_almost_equal(self.dist(self.breast[:2].X, self.breast[3].x), - np.array([[0.4983256], - [0.42682613]])) - - + np.testing.assert_almost_equal( + self.dist(self.breast[0].x, self.breast[1].x, axis=1), + np.array([[0.48462293898088876]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2].X), + np.array([[0., 0.48462294], + [0.48462294, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[2].x, self.breast[:3].X), + np.array([[0.10133593, 0.32783865, 0.]])) + np.testing.assert_almost_equal( + self.dist(self.breast[:2].X, self.breast[3].x), + np.array([[0.4983256], + [0.42682613]])) + + +# noinspection PyTypeChecker # Pylint doesn't get magic __new__ operators # pylint: disable=not-callable class TestMahalanobis(TestCase): @@ -652,7 +844,8 @@ def test_correctness(self): d = scipy.spatial.distance.squareform(d) for i in range(self.n): for j in range(self.n): - self.assertAlmostEqual(d[i][j], mah(self.x[i], self.x[j]), delta=1e-5) + self.assertAlmostEqual(d[i][j], mah(self.x[i], self.x[j]), + delta=1e-5) def test_attributes(self): metric = MahalanobisDistance(self.x) From 5969543906604208fe1aafdd148d790254ca2698 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 18 Aug 2017 11:04:04 +0200 Subject: [PATCH 26/27] Distances: Add distances/tests/__init__.py --- Orange/distance/tests/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 Orange/distance/tests/__init__.py diff --git a/Orange/distance/tests/__init__.py b/Orange/distance/tests/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/Orange/distance/tests/__init__.py @@ -0,0 +1 @@ + From 13ede450513a3e8aac793dc154b26dc73c864673 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 25 Aug 2017 11:33:57 +0200 Subject: [PATCH 27/27] distances: Convert lower to symetric only once --- Orange/distance/_distance.c | 6685 ++++++++++++++++++++++----------- Orange/distance/_distance.pyx | 13 +- Orange/distance/distance.py | 4 + 3 files changed, 4599 insertions(+), 2103 deletions(-) diff --git a/Orange/distance/_distance.c b/Orange/distance/_distance.c index e2db68fe3a5..765b89125cd 100644 --- a/Orange/distance/_distance.c +++ b/Orange/distance/_distance.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.24.1 */ +/* Generated by Cython 0.26 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,7 +7,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else -#define CYTHON_ABI "0_24_1" +#define CYTHON_ABI "0_26" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -29,6 +29,12 @@ #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #define HAVE_LONG_LONG + #endif +#endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif @@ -37,13 +43,110 @@ #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 #else #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif #endif -#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 - #define CYTHON_USE_PYLONG_INTERNALS 1 +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" @@ -79,24 +182,48 @@ #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif +#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 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)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY @@ -121,6 +248,13 @@ #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 @@ -149,6 +283,7 @@ #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -187,18 +322,26 @@ #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#if PY_VERSION_HEX >= 0x030500B1 -#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods -#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) -#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; -} __Pyx_PyAsyncMethodsStruct; -#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif #else -#define __Pyx_PyType_AsAsync(obj) NULL + #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -211,10 +354,68 @@ typedef struct { #define CYTHON_RESTRICT #endif #endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #ifdef __cplusplus + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__)) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif #ifndef CYTHON_INLINE - #if defined(__GNUC__) + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline @@ -268,9 +469,9 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__Orange__distance___distance #define __PYX_HAVE_API__Orange__distance___distance -#include "string.h" -#include "stdio.h" -#include "stdlib.h" +#include +#include +#include #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "numpy/npy_math.h" @@ -285,26 +486,6 @@ static CYTHON_INLINE float __PYX_NAN() { #define CYTHON_WITHOUT_ASSERTIONS #endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; @@ -341,8 +522,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString @@ -355,8 +536,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif -#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) @@ -382,7 +566,7 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) @@ -478,10 +662,12 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -490,7 +676,7 @@ static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; -/* None.proto */ +/* Header.proto */ #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 @@ -519,6 +705,16 @@ static const char *__pyx_f[] = { "stringsource", "type.pxd", }; +/* MemviewSliceStruct.proto */ +struct __pyx_memoryview_obj; +typedef struct { + struct __pyx_memoryview_obj *memview; + char *data; + Py_ssize_t shape[8]; + Py_ssize_t strides[8]; + Py_ssize_t suboffsets[8]; +} __Pyx_memviewslice; + /* BufferFormatStructs.proto */ #define IS_UNSIGNED(type) (((type) -1) > 0) struct __Pyx_StructField_; @@ -555,16 +751,6 @@ typedef struct { char is_valid_array; } __Pyx_BufFmt_Context; -/* MemviewSliceStruct.proto */ -struct __pyx_memoryview_obj; -typedef struct { - struct __pyx_memoryview_obj *memview; - char *data; - Py_ssize_t shape[8]; - Py_ssize_t strides[8]; - Py_ssize_t suboffsets[8]; -} __Pyx_memviewslice; - /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS @@ -615,7 +801,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; #endif -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":725 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -624,7 +810,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":726 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -633,7 +819,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":727 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -642,7 +828,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":728 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -651,7 +837,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":732 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -660,7 +846,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":733 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -669,7 +855,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":734 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -678,7 +864,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":735 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -687,7 +873,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":739 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -696,7 +882,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":740 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -705,7 +891,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":749 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -714,7 +900,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":750 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -723,7 +909,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":751 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -732,7 +918,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":753 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -741,7 +927,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":754 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -750,7 +936,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":755 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -759,7 +945,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":757 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -768,7 +954,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":758 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -777,7 +963,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":760 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -786,7 +972,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":761 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -795,7 +981,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":762 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -803,7 +989,7 @@ typedef npy_double __pyx_t_5numpy_double_t; * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* None.proto */ +/* Declarations.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; @@ -813,8 +999,9 @@ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); -/* None.proto */ +/* Declarations.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; @@ -824,6 +1011,7 @@ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); /*--- Type declarations ---*/ @@ -832,7 +1020,7 @@ struct __pyx_MemviewEnum_obj; struct __pyx_memoryview_obj; struct __pyx_memoryviewslice_obj; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":764 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -841,7 +1029,7 @@ struct __pyx_memoryviewslice_obj; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":765 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -850,7 +1038,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":766 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -859,7 +1047,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":768 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1058,7 +1246,7 @@ static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) @@ -1076,21 +1264,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +/* None.proto */ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); /* BufferFormatCheck.proto */ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, @@ -1099,10 +1274,8 @@ static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); // PROTO + __Pyx_TypeInfo* type); -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) /* MemviewSliceInit.proto */ #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d #define __Pyx_MEMVIEW_DIRECT 1 @@ -1129,8 +1302,33 @@ static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) /* PyThreadStateGet.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); #else @@ -1139,7 +1337,7 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); #endif /* PyErrFetchRestore.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) @@ -1202,6 +1400,33 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + /* IncludeStringH.proto */ #include @@ -1227,41 +1452,31 @@ static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/ /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); +/* decode_c_string_utf16.proto */ +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + /* decode_c_string.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); -/* SaveResetException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif +/* GetAttr3.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /* SwapException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else @@ -1271,6 +1486,24 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ @@ -1295,7 +1528,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ /* ListCompAppend.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); @@ -1312,7 +1545,7 @@ static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { #endif /* PyIntBinop.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ @@ -1333,7 +1566,7 @@ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { } /* ListAppend.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); @@ -1349,9 +1582,6 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif -/* None.proto */ -static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); - /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 @@ -1370,9 +1600,21 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* HasAttr.proto */ +static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); + /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); +/* SetupReduce.proto */ +static int __Pyx_setup_reduce(PyObject* type_obj); + +/* CLineInTraceback.proto */ +static int __Pyx_CLineForTraceback(int c_line); + /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; @@ -1461,7 +1703,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); -/* None.proto */ +/* RealImag.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) @@ -1474,7 +1716,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) +#if defined(__cplusplus) && CYTHON_CCOMPLEX\ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else @@ -1482,85 +1725,79 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif -/* None.proto */ -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* None.proto */ +/* Arithmetic.proto */ #if CYTHON_CCOMPLEX - #define __Pyx_c_eqf(a, b) ((a)==(b)) - #define __Pyx_c_sumf(a, b) ((a)+(b)) - #define __Pyx_c_difff(a, b) ((a)-(b)) - #define __Pyx_c_prodf(a, b) ((a)*(b)) - #define __Pyx_c_quotf(a, b) ((a)/(b)) - #define __Pyx_c_negf(a) (-(a)) + #define __Pyx_c_eq_float(a, b) ((a)==(b)) + #define __Pyx_c_sum_float(a, b) ((a)+(b)) + #define __Pyx_c_diff_float(a, b) ((a)-(b)) + #define __Pyx_c_prod_float(a, b) ((a)*(b)) + #define __Pyx_c_quot_float(a, b) ((a)/(b)) + #define __Pyx_c_neg_float(a) (-(a)) #ifdef __cplusplus - #define __Pyx_c_is_zerof(z) ((z)==(float)0) - #define __Pyx_c_conjf(z) (::std::conj(z)) + #define __Pyx_c_is_zero_float(z) ((z)==(float)0) + #define __Pyx_c_conj_float(z) (::std::conj(z)) #if 1 - #define __Pyx_c_absf(z) (::std::abs(z)) - #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #define __Pyx_c_abs_float(z) (::std::abs(z)) + #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) #endif #else - #define __Pyx_c_is_zerof(z) ((z)==0) - #define __Pyx_c_conjf(z) (conjf(z)) + #define __Pyx_c_is_zero_float(z) ((z)==0) + #define __Pyx_c_conj_float(z) (conjf(z)) #if 1 - #define __Pyx_c_absf(z) (cabsf(z)) - #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #define __Pyx_c_abs_float(z) (cabsf(z)) + #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) #endif #endif #else - static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); #if 1 - static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif -/* None.proto */ -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - -/* None.proto */ +/* Arithmetic.proto */ #if CYTHON_CCOMPLEX - #define __Pyx_c_eq(a, b) ((a)==(b)) - #define __Pyx_c_sum(a, b) ((a)+(b)) - #define __Pyx_c_diff(a, b) ((a)-(b)) - #define __Pyx_c_prod(a, b) ((a)*(b)) - #define __Pyx_c_quot(a, b) ((a)/(b)) - #define __Pyx_c_neg(a) (-(a)) + #define __Pyx_c_eq_double(a, b) ((a)==(b)) + #define __Pyx_c_sum_double(a, b) ((a)+(b)) + #define __Pyx_c_diff_double(a, b) ((a)-(b)) + #define __Pyx_c_prod_double(a, b) ((a)*(b)) + #define __Pyx_c_quot_double(a, b) ((a)/(b)) + #define __Pyx_c_neg_double(a) (-(a)) #ifdef __cplusplus - #define __Pyx_c_is_zero(z) ((z)==(double)0) - #define __Pyx_c_conj(z) (::std::conj(z)) + #define __Pyx_c_is_zero_double(z) ((z)==(double)0) + #define __Pyx_c_conj_double(z) (::std::conj(z)) #if 1 - #define __Pyx_c_abs(z) (::std::abs(z)) - #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #define __Pyx_c_abs_double(z) (::std::abs(z)) + #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) #endif #else - #define __Pyx_c_is_zero(z) ((z)==0) - #define __Pyx_c_conj(z) (conj(z)) + #define __Pyx_c_is_zero_double(z) ((z)==0) + #define __Pyx_c_conj_double(z) (conj(z)) #if 1 - #define __Pyx_c_abs(z) (cabs(z)) - #define __Pyx_c_pow(a, b) (cpow(a, b)) + #define __Pyx_c_abs_double(z) (cabs(z)) + #define __Pyx_c_pow_double(a, b) (cpow(a, b)) #endif #endif #else - static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); #if 1 - static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif @@ -1580,12 +1817,12 @@ static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1659,7 +1896,7 @@ static PyObject *contiguous = 0; static PyObject *indirect_contiguous = 0; static int __pyx_memoryview_thread_locks_used; static PyThread_type_lock __pyx_memoryview_thread_locks[8]; -static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice); /*proto*/ +static void __pyx_f_6Orange_8distance_9_distance_lower_to_symmetric(__Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/ static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ static void *__pyx_align_pointer(void *, size_t); /*proto*/ static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ @@ -1692,6 +1929,7 @@ static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/ static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/ +static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t = { "int8_t", NULL, sizeof(__pyx_t_5numpy_int8_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int8_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int8_t), 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; @@ -1702,10 +1940,11 @@ int __pyx_module_is_main_Orange__distance___distance = 0; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_ImportError; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_enumerate; -static PyObject *__pyx_builtin_Ellipsis; static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_Ellipsis; static PyObject *__pyx_builtin_id; static PyObject *__pyx_builtin_IndexError; static const char __pyx_k_O[] = "O"; @@ -1718,12 +1957,14 @@ static const char __pyx_k_ps[] = "ps"; static const char __pyx_k_x1[] = "x1"; static const char __pyx_k_x2[] = "x2"; static const char __pyx_k_col[] = "col"; +static const char __pyx_k_new[] = "__new__"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_row[] = "row"; static const char __pyx_k_val[] = "val"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_col1[] = "col1"; static const char __pyx_k_col2[] = "col2"; +static const char __pyx_k_dict[] = "__dict__"; static const char __pyx_k_int8[] = "int8"; static const char __pyx_k_mads[] = "mads"; static const char __pyx_k_main[] = "__main__"; @@ -1764,8 +2005,11 @@ static const char __pyx_k_in_any[] = "in_any"; static const char __pyx_k_n_cols[] = "n_cols"; static const char __pyx_k_n_rows[] = "n_rows"; static const char __pyx_k_name_2[] = "__name__"; +static const char __pyx_k_pickle[] = "pickle"; +static const char __pyx_k_result[] = "result"; static const char __pyx_k_struct[] = "struct"; static const char __pyx_k_unpack[] = "unpack"; +static const char __pyx_k_update[] = "update"; static const char __pyx_k_fortran[] = "fortran"; static const char __pyx_k_in_both[] = "in_both"; static const char __pyx_k_medians[] = "medians"; @@ -1777,6 +2021,7 @@ static const char __pyx_k_Ellipsis[] = "Ellipsis"; static const char __pyx_k_in1_unk2[] = "in1_unk2"; static const char __pyx_k_itemsize[] = "itemsize"; static const char __pyx_k_nonzeros[] = "nonzeros"; +static const char __pyx_k_pyx_type[] = "__pyx_type"; static const char __pyx_k_unk1_in2[] = "unk1_in2"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_distances[] = "distances"; @@ -1786,24 +2031,34 @@ static const char __pyx_k_nonzeros2[] = "nonzeros2"; static const char __pyx_k_normalize[] = "normalize"; static const char __pyx_k_not1_unk2[] = "not1_unk2"; static const char __pyx_k_p_nonzero[] = "p_nonzero"; +static const char __pyx_k_pyx_state[] = "__pyx_state"; static const char __pyx_k_unk1_not2[] = "unk1_not2"; static const char __pyx_k_unk1_unk2[] = "unk1_unk2"; static const char __pyx_k_IndexError[] = "IndexError"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_two_tables[] = "two_tables"; +static const char __pyx_k_ImportError[] = "ImportError"; static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_PickleError[] = "PickleError"; static const char __pyx_k_any_nan_row[] = "any_nan_row"; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_dist_missing[] = "dist_missing"; static const char __pyx_k_intersection[] = "intersection"; static const char __pyx_k_jaccard_cols[] = "jaccard_cols"; static const char __pyx_k_jaccard_rows[] = "jaccard_rows"; +static const char __pyx_k_pyx_checksum[] = "__pyx_checksum"; +static const char __pyx_k_stringsource[] = "stringsource"; static const char __pyx_k_dist_missing2[] = "dist_missing2"; static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; +static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_manhattan_cols[] = "manhattan_cols"; +static const char __pyx_k_View_MemoryView[] = "View.MemoryView"; static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; +static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; +static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_dist_missing2_cont[] = "dist_missing2_cont"; static const char __pyx_k_fix_euclidean_cols[] = "fix_euclidean_cols"; static const char __pyx_k_fix_euclidean_rows[] = "fix_euclidean_rows"; @@ -1821,17 +2076,19 @@ static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis % static const char __pyx_k_Orange_distance__distance[] = "Orange.distance._distance"; static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_Orange_distance__distance_pyx[] = "Orange/distance/_distance.pyx"; static const char __pyx_k_fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized"; static const char __pyx_k_fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized"; static const char __pyx_k_fix_manhattan_rows_normalized[] = "fix_manhattan_rows_normalized"; static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static const char __pyx_k_strided_and_direct_or_indirect[] = ""; -static const char __pyx_k_Users_janez_Dropbox_orange3_Ora[] = "/Users/janez/Dropbox/orange3/Orange/distance/_distance.pyx"; +static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory."; static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array"; static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))"; static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported"; static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s"; static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; @@ -1839,6 +2096,8 @@ static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object"; static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)"; static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides."; static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_ASCII; @@ -1849,6 +2108,8 @@ static PyObject *__pyx_n_s_Ellipsis; static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_ImportError; +static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0; static PyObject *__pyx_n_s_IndexError; static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte; static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr; @@ -1859,24 +2120,28 @@ static PyObject *__pyx_kp_s_MemoryView_of_r_object; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_b_O; static PyObject *__pyx_n_s_Orange_distance__distance; +static PyObject *__pyx_kp_s_Orange_distance__distance_pyx; static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; +static PyObject *__pyx_n_s_PickleError; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; -static PyObject *__pyx_kp_s_Users_janez_Dropbox_orange3_Ora; static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_View_MemoryView; static PyObject *__pyx_n_s_allocate_buffer; static PyObject *__pyx_n_s_any_nan_row; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_c; static PyObject *__pyx_n_u_c; static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_col; static PyObject *__pyx_n_s_col1; static PyObject *__pyx_n_s_col2; static PyObject *__pyx_kp_s_contiguous_and_direct; static PyObject *__pyx_kp_s_contiguous_and_indirect; static PyObject *__pyx_n_s_d; +static PyObject *__pyx_n_s_dict; static PyObject *__pyx_n_s_dist_missing; static PyObject *__pyx_n_s_dist_missing2; static PyObject *__pyx_n_s_dist_missing2_cont; @@ -1931,6 +2196,8 @@ static PyObject *__pyx_n_s_nans2; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_ndim; +static PyObject *__pyx_n_s_new; +static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_s_nonnans; static PyObject *__pyx_n_s_nonzeros; static PyObject *__pyx_n_s_nonzeros1; @@ -1939,16 +2206,26 @@ static PyObject *__pyx_n_s_normalize; static PyObject *__pyx_n_s_not1_unk2; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; +static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; static PyObject *__pyx_n_s_obj; static PyObject *__pyx_n_s_p_nonzero; static PyObject *__pyx_n_s_pack; +static PyObject *__pyx_n_s_pickle; static PyObject *__pyx_n_s_ps; +static PyObject *__pyx_n_s_pyx_checksum; static PyObject *__pyx_n_s_pyx_getbuffer; +static PyObject *__pyx_n_s_pyx_state; +static PyObject *__pyx_n_s_pyx_type; +static PyObject *__pyx_n_s_pyx_unpickle_Enum; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_result; static PyObject *__pyx_n_s_row; static PyObject *__pyx_n_s_row1; static PyObject *__pyx_n_s_row2; +static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_shape; static PyObject *__pyx_n_s_size; static PyObject *__pyx_n_s_start; @@ -1957,6 +2234,7 @@ static PyObject *__pyx_n_s_stop; static PyObject *__pyx_kp_s_strided_and_direct; static PyObject *__pyx_kp_s_strided_and_direct_or_indirect; static PyObject *__pyx_kp_s_strided_and_indirect; +static PyObject *__pyx_kp_s_stringsource; static PyObject *__pyx_n_s_struct; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_two_tables; @@ -1968,6 +2246,7 @@ static PyObject *__pyx_n_s_unk1_not2; static PyObject *__pyx_n_s_unk1_unk2; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_unpack; +static PyObject *__pyx_n_s_update; static PyObject *__pyx_n_s_val; static PyObject *__pyx_n_s_val1; static PyObject *__pyx_n_s_val2; @@ -1976,19 +2255,20 @@ static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_x1; static PyObject *__pyx_n_s_x2; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables); /* proto */ -static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_lower_to_symmetric(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_distances); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables); /* proto */ +static PyObject *__pyx_pf_6Orange_8distance_9_distance_26jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ @@ -1998,8 +2278,12 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct _ static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ @@ -2021,14 +2305,20 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; +static PyObject *__pyx_int_184977713; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; @@ -2039,57 +2329,69 @@ static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; -static PyObject *__pyx_slice__16; -static PyObject *__pyx_slice__17; -static PyObject *__pyx_slice__18; +static PyObject *__pyx_slice__23; +static PyObject *__pyx_slice__24; +static PyObject *__pyx_slice__25; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__18; static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__21; static PyObject *__pyx_tuple__22; -static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__27; static PyObject *__pyx_tuple__28; -static PyObject *__pyx_tuple__30; -static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__34; -static PyObject *__pyx_tuple__36; -static PyObject *__pyx_tuple__38; -static PyObject *__pyx_tuple__40; -static PyObject *__pyx_tuple__42; -static PyObject *__pyx_tuple__44; -static PyObject *__pyx_tuple__46; +static PyObject *__pyx_tuple__29; +static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_tuple__35; +static PyObject *__pyx_tuple__37; +static PyObject *__pyx_tuple__39; +static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__43; +static PyObject *__pyx_tuple__45; static PyObject *__pyx_tuple__47; -static PyObject *__pyx_tuple__48; static PyObject *__pyx_tuple__49; -static PyObject *__pyx_tuple__50; -static PyObject *__pyx_codeobj__21; -static PyObject *__pyx_codeobj__23; -static PyObject *__pyx_codeobj__25; -static PyObject *__pyx_codeobj__27; -static PyObject *__pyx_codeobj__29; -static PyObject *__pyx_codeobj__31; -static PyObject *__pyx_codeobj__33; -static PyObject *__pyx_codeobj__35; -static PyObject *__pyx_codeobj__37; -static PyObject *__pyx_codeobj__39; -static PyObject *__pyx_codeobj__41; -static PyObject *__pyx_codeobj__43; -static PyObject *__pyx_codeobj__45; +static PyObject *__pyx_tuple__51; +static PyObject *__pyx_tuple__53; +static PyObject *__pyx_tuple__55; +static PyObject *__pyx_tuple__56; +static PyObject *__pyx_tuple__57; +static PyObject *__pyx_tuple__58; +static PyObject *__pyx_tuple__59; +static PyObject *__pyx_tuple__60; +static PyObject *__pyx_codeobj__30; +static PyObject *__pyx_codeobj__32; +static PyObject *__pyx_codeobj__34; +static PyObject *__pyx_codeobj__36; +static PyObject *__pyx_codeobj__38; +static PyObject *__pyx_codeobj__40; +static PyObject *__pyx_codeobj__42; +static PyObject *__pyx_codeobj__44; +static PyObject *__pyx_codeobj__46; +static PyObject *__pyx_codeobj__48; +static PyObject *__pyx_codeobj__50; +static PyObject *__pyx_codeobj__52; +static PyObject *__pyx_codeobj__54; +static PyObject *__pyx_codeobj__61; /* "Orange/distance/_distance.pyx":18 * * - * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cpdef void lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< * cdef int row1, row2 * for row1 in range(distances.shape[0]): */ -static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memviewslice __pyx_v_distances) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1lower_to_symmetric(PyObject *__pyx_self, PyObject *__pyx_arg_distances); /*proto*/ +static void __pyx_f_6Orange_8distance_9_distance_lower_to_symmetric(__Pyx_memviewslice __pyx_v_distances, CYTHON_UNUSED int __pyx_skip_dispatch) { int __pyx_v_row1; int __pyx_v_row2; __Pyx_RefNannyDeclarations @@ -2101,10 +2403,10 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi Py_ssize_t __pyx_t_6; Py_ssize_t __pyx_t_7; Py_ssize_t __pyx_t_8; - __Pyx_RefNannySetupContext("_lower_to_symmetric", 0); + __Pyx_RefNannySetupContext("lower_to_symmetric", 0); /* "Orange/distance/_distance.pyx":20 - * cdef void _lower_to_symmetric(double [:, :] distances): + * cpdef void lower_to_symmetric(double [:, :] distances): * cdef int row1, row2 * for row1 in range(distances.shape[0]): # <<<<<<<<<<<<<< * for row2 in range(row1): @@ -2143,7 +2445,7 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi /* "Orange/distance/_distance.pyx":18 * * - * cdef void _lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< + * cpdef void lower_to_symmetric(double [:, :] distances): # <<<<<<<<<<<<<< * cdef int row1, row2 * for row1 in range(distances.shape[0]): */ @@ -2152,22 +2454,71 @@ static void __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__Pyx_memvi __Pyx_RefNannyFinishContext(); } -/* "Orange/distance/_distance.pyx":25 - * - * - * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< - * np.ndarray[np.float64_t, ndim=2] x1, - * np.ndarray[np.float64_t, ndim=2] x2, - */ - /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_euclidean_rows_discrete[] = "euclidean_rows_discrete(ndarray distances, ndarray x1, ndarray x2, __Pyx_memviewslice dist_missing, ndarray dist_missing2, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows_discrete = {"euclidean_rows_discrete", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_euclidean_rows_discrete}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_distances = 0; - PyArrayObject *__pyx_v_x1 = 0; - PyArrayObject *__pyx_v_x2 = 0; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1lower_to_symmetric(PyObject *__pyx_self, PyObject *__pyx_arg_distances); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_lower_to_symmetric[] = "lower_to_symmetric(__Pyx_memviewslice distances) -> void"; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_1lower_to_symmetric(PyObject *__pyx_self, PyObject *__pyx_arg_distances) { + __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("lower_to_symmetric (wrapper)", 0); + assert(__pyx_arg_distances); { + __pyx_v_distances = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_arg_distances); if (unlikely(!__pyx_v_distances.memview)) __PYX_ERR(0, 18, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("Orange.distance._distance.lower_to_symmetric", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_lower_to_symmetric(__pyx_self, __pyx_v_distances); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6Orange_8distance_9_distance_lower_to_symmetric(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_distances) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("lower_to_symmetric", 0); + __Pyx_XDECREF(__pyx_r); + if (unlikely(!__pyx_v_distances.memview)) { __Pyx_RaiseUnboundLocalError("distances"); __PYX_ERR(0, 18, __pyx_L1_error) } + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6Orange_8distance_9_distance_lower_to_symmetric(__pyx_v_distances, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __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("Orange.distance._distance.lower_to_symmetric", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "Orange/distance/_distance.pyx":25 + * + * + * def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< + * np.ndarray[np.float64_t, ndim=2] x1, + * np.ndarray[np.float64_t, ndim=2] x2, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_2euclidean_rows_discrete[] = "euclidean_rows_discrete(ndarray distances, ndarray x1, ndarray x2, __Pyx_memviewslice dist_missing, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_3euclidean_rows_discrete = {"euclidean_rows_discrete", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_3euclidean_rows_discrete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_2euclidean_rows_discrete}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_3euclidean_rows_discrete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_distances = 0; + PyArrayObject *__pyx_v_x1 = 0; + PyArrayObject *__pyx_v_x2 = 0; __Pyx_memviewslice __pyx_v_dist_missing = { 0, 0, { 0 }, { 0 }, { 0 } }; PyArrayObject *__pyx_v_dist_missing2 = 0; char __pyx_v_two_tables; @@ -2182,11 +2533,17 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete( const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + CYTHON_FALLTHROUGH; 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; } @@ -2195,26 +2552,31 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete( case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 1); __PYX_ERR(0, 25, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 2); __PYX_ERR(0, 25, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 3); __PYX_ERR(0, 25, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("euclidean_rows_discrete", 1, 6, 6, 4); __PYX_ERR(0, 25, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { @@ -2253,7 +2615,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete( if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 26, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 27, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 29, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_dist_missing, __pyx_v_dist_missing2, __pyx_v_two_tables); + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2euclidean_rows_discrete(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_dist_missing, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -2264,7 +2626,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_1euclidean_rows_discrete( return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_2euclidean_rows_discrete(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, __Pyx_memviewslice __pyx_v_dist_missing, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -2308,7 +2670,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - __Pyx_memviewslice __pyx_t_23 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannySetupContext("euclidean_rows_discrete", 0); __pyx_pybuffer_distances.pybuffer.buf = NULL; __pyx_pybuffer_distances.refcount = 0; @@ -2379,6 +2740,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { @@ -2564,7 +2926,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C * elif ival1 != ival2: * d += 1 # <<<<<<<<<<<<<< * distances[row1, row2] += d - * if not two_tables: + * */ __pyx_v_d = (__pyx_v_d + 1.0); @@ -2583,8 +2945,8 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C * elif ival1 != ival2: * d += 1 * distances[row1, row2] += d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) + * + * */ __pyx_t_21 = __pyx_v_row1; __pyx_t_22 = __pyx_v_row2; @@ -2603,6 +2965,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -2611,37 +2974,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C } } - /* "Orange/distance/_distance.pyx":55 - * d += 1 - * distances[row1, row2] += d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * - */ - __pyx_t_15 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_15) { - - /* "Orange/distance/_distance.pyx":56 - * distances[row1, row2] += d - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); - if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 56, __pyx_L1_error) - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_23); - __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1); - - /* "Orange/distance/_distance.pyx":55 - * d += 1 - * distances[row1, row2] += d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * - */ - } - /* "Orange/distance/_distance.pyx":25 * * @@ -2654,7 +2986,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -2679,7 +3010,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C return __pyx_r; } -/* "Orange/distance/_distance.pyx":59 +/* "Orange/distance/_distance.pyx":57 * * * def fix_euclidean_rows( # <<<<<<<<<<<<<< @@ -2688,10 +3019,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_euclidean_rows_discrete(C */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_2fix_euclidean_rows[] = "fix_euclidean_rows(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_3fix_euclidean_rows = {"fix_euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_2fix_euclidean_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows[] = "fix_euclidean_rows(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows = {"fix_euclidean_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; @@ -2710,12 +3041,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObj const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + CYTHON_FALLTHROUGH; 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; } @@ -2724,39 +3062,45 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObj case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 1); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 1); __PYX_ERR(0, 57, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 2); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 2); __PYX_ERR(0, 57, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 3); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 3); __PYX_ERR(0, 57, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 4); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 4); __PYX_ERR(0, 57, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 5); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 5); __PYX_ERR(0, 57, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 6); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, 6); __PYX_ERR(0, 57, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows") < 0)) __PYX_ERR(0, 59, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows") < 0)) __PYX_ERR(0, 57, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { goto __pyx_L5_argtuple_error; @@ -2775,23 +3119,23 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObj __pyx_v_means = ((PyArrayObject *)values[3]); __pyx_v_vars = ((PyArrayObject *)values[4]); __pyx_v_dist_missing2 = ((PyArrayObject *)values[5]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 64, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 57, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 60, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 61, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 62, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 63, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 64, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 65, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 58, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 60, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 61, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 62, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -2802,7 +3146,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_3fix_euclidean_rows(PyObj return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_means, PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -2879,36 +3223,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_pybuffernd_dist_missing2.rcbuffer = &__pyx_pybuffer_dist_missing2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_vars.diminfo[0].strides = __pyx_pybuffernd_vars.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vars.diminfo[0].shape = __pyx_pybuffernd_vars.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 59, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 57, __pyx_L1_error) } __pyx_pybuffernd_dist_missing2.diminfo[0].strides = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2.diminfo[0].shape = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":71 + /* "Orange/distance/_distance.pyx":69 * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -2920,7 +3264,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":72 + /* "Orange/distance/_distance.pyx":70 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -2929,7 +3273,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":73 + /* "Orange/distance/_distance.pyx":71 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< @@ -2940,10 +3284,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":74 + /* "Orange/distance/_distance.pyx":72 * n_rows2 = x2.shape[0] * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -2954,7 +3299,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":75 + /* "Orange/distance/_distance.pyx":73 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -2969,7 +3314,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":76 + /* "Orange/distance/_distance.pyx":74 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -2981,7 +3326,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":77 + /* "Orange/distance/_distance.pyx":75 * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): * d = 0 # <<<<<<<<<<<<<< @@ -2990,7 +3335,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":78 + /* "Orange/distance/_distance.pyx":76 * if npy_isnan(distances[row1, row2]): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -3001,7 +3346,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":79 + /* "Orange/distance/_distance.pyx":77 * d = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -3017,7 +3362,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":80 + /* "Orange/distance/_distance.pyx":78 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3027,7 +3372,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":81 + /* "Orange/distance/_distance.pyx":79 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3037,7 +3382,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":82 + /* "Orange/distance/_distance.pyx":80 * if npy_isnan(val1): * if npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -3047,7 +3392,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_18 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":81 + /* "Orange/distance/_distance.pyx":79 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3057,7 +3402,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":84 + /* "Orange/distance/_distance.pyx":82 * d += dist_missing2[col] * else: * d += (val2 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3071,7 +3416,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO } __pyx_L14:; - /* "Orange/distance/_distance.pyx":80 + /* "Orange/distance/_distance.pyx":78 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3081,7 +3426,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":85 + /* "Orange/distance/_distance.pyx":83 * else: * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3091,7 +3436,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":86 + /* "Orange/distance/_distance.pyx":84 * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): * d += (val1 - means[col]) ** 2 + vars[col] # <<<<<<<<<<<<<< @@ -3102,7 +3447,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_22 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_means.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_means.diminfo[0].strides))), 2.0) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_vars.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_vars.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":85 + /* "Orange/distance/_distance.pyx":83 * else: * d += (val2 - means[col]) ** 2 + vars[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3112,7 +3457,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":88 + /* "Orange/distance/_distance.pyx":86 * d += (val1 - means[col]) ** 2 + vars[col] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3125,7 +3470,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_L13:; } - /* "Orange/distance/_distance.pyx":89 + /* "Orange/distance/_distance.pyx":87 * else: * d += (val1 - val2) ** 2 * distances[row1, row2] = d # <<<<<<<<<<<<<< @@ -3136,7 +3481,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_24 = __pyx_v_row2; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":90 + /* "Orange/distance/_distance.pyx":88 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3146,7 +3491,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":91 + /* "Orange/distance/_distance.pyx":89 * distances[row1, row2] = d * if not two_tables: * distances[row2, row1] = d # <<<<<<<<<<<<<< @@ -3157,7 +3502,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO __pyx_t_26 = __pyx_v_row1; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":90 + /* "Orange/distance/_distance.pyx":88 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3166,7 +3511,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO */ } - /* "Orange/distance/_distance.pyx":76 + /* "Orange/distance/_distance.pyx":74 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -3178,7 +3523,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO } } - /* "Orange/distance/_distance.pyx":73 + /* "Orange/distance/_distance.pyx":71 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< @@ -3188,6 +3533,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -3196,7 +3542,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO } } - /* "Orange/distance/_distance.pyx":59 + /* "Orange/distance/_distance.pyx":57 * * * def fix_euclidean_rows( # <<<<<<<<<<<<<< @@ -3235,7 +3581,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO return __pyx_r; } -/* "Orange/distance/_distance.pyx":94 +/* "Orange/distance/_distance.pyx":92 * * * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< @@ -3244,10 +3590,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_2fix_euclidean_rows(CYTHO */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized = {"fix_euclidean_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_rows_normalized[] = "fix_euclidean_rows_normalized(ndarray distances, ndarray x1, ndarray x2, ndarray means, ndarray vars, ndarray dist_missing2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_rows_normalized = {"fix_euclidean_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_rows_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; @@ -3266,12 +3612,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_norma const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + CYTHON_FALLTHROUGH; 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; } @@ -3280,39 +3633,45 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_norma case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 1); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 1); __PYX_ERR(0, 92, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 2); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 2); __PYX_ERR(0, 92, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 3); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 3); __PYX_ERR(0, 92, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 4); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 4); __PYX_ERR(0, 92, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 5); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 5); __PYX_ERR(0, 92, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 6); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, 6); __PYX_ERR(0, 92, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows_normalized") < 0)) __PYX_ERR(0, 94, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_rows_normalized") < 0)) __PYX_ERR(0, 92, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { goto __pyx_L5_argtuple_error; @@ -3331,23 +3690,23 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_norma __pyx_v_means = ((PyArrayObject *)values[3]); __pyx_v_vars = ((PyArrayObject *)values[4]); __pyx_v_dist_missing2 = ((PyArrayObject *)values[5]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 99, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 94, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_rows_normalized", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 92, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 95, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 96, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 97, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 98, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 99, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 100, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 93, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 95, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_means), __pyx_ptype_5numpy_ndarray, 1, "means", 0))) __PYX_ERR(0, 96, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vars), __pyx_ptype_5numpy_ndarray, 1, "vars", 0))) __PYX_ERR(0, 97, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2", 0))) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_means, __pyx_v_vars, __pyx_v_dist_missing2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -3358,7 +3717,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_5fix_euclidean_rows_norma return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, CYTHON_UNUSED PyArrayObject *__pyx_v_means, CYTHON_UNUSED PyArrayObject *__pyx_v_vars, PyArrayObject *__pyx_v_dist_missing2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -3431,36 +3790,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_pybuffernd_dist_missing2.rcbuffer = &__pyx_pybuffer_dist_missing2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vars.rcbuffer->pybuffer, (PyObject*)__pyx_v_vars, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_vars.diminfo[0].strides = __pyx_pybuffernd_vars.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vars.diminfo[0].shape = __pyx_pybuffernd_vars.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 94, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error) } __pyx_pybuffernd_dist_missing2.diminfo[0].strides = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2.diminfo[0].shape = __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":106 + /* "Orange/distance/_distance.pyx":104 * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -3472,7 +3831,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":107 + /* "Orange/distance/_distance.pyx":105 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -3481,7 +3840,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":108 + /* "Orange/distance/_distance.pyx":106 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< @@ -3492,10 +3851,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":109 + /* "Orange/distance/_distance.pyx":107 * n_rows2 = x2.shape[0] * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -3506,7 +3866,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":110 + /* "Orange/distance/_distance.pyx":108 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -3521,7 +3881,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":111 + /* "Orange/distance/_distance.pyx":109 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -3533,7 +3893,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":112 + /* "Orange/distance/_distance.pyx":110 * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): * d = 0 # <<<<<<<<<<<<<< @@ -3542,7 +3902,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":113 + /* "Orange/distance/_distance.pyx":111 * if npy_isnan(distances[row1, row2]): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -3553,7 +3913,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":114 + /* "Orange/distance/_distance.pyx":112 * d = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -3569,7 +3929,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":113 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3579,7 +3939,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":114 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3589,7 +3949,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":117 + /* "Orange/distance/_distance.pyx":115 * if npy_isnan(val1): * if npy_isnan(val2): * d += dist_missing2[col] # <<<<<<<<<<<<<< @@ -3599,7 +3959,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_18 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":116 + /* "Orange/distance/_distance.pyx":114 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3609,7 +3969,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":119 + /* "Orange/distance/_distance.pyx":117 * d += dist_missing2[col] * else: * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3621,7 +3981,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma } __pyx_L14:; - /* "Orange/distance/_distance.pyx":115 + /* "Orange/distance/_distance.pyx":113 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -3631,7 +3991,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":120 + /* "Orange/distance/_distance.pyx":118 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3641,7 +4001,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":121 + /* "Orange/distance/_distance.pyx":119 * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -3650,7 +4010,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma */ __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":120 + /* "Orange/distance/_distance.pyx":118 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -3660,7 +4020,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":123 + /* "Orange/distance/_distance.pyx":121 * d += val1 ** 2 + 0.5 * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -3673,7 +4033,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_L13:; } - /* "Orange/distance/_distance.pyx":124 + /* "Orange/distance/_distance.pyx":122 * else: * d += (val1 - val2) ** 2 * distances[row1, row2] = d # <<<<<<<<<<<<<< @@ -3684,7 +4044,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_20 = __pyx_v_row2; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":123 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3694,7 +4054,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":126 + /* "Orange/distance/_distance.pyx":124 * distances[row1, row2] = d * if not two_tables: * distances[row2, row1] = d # <<<<<<<<<<<<<< @@ -3705,7 +4065,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma __pyx_t_22 = __pyx_v_row1; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":125 + /* "Orange/distance/_distance.pyx":123 * d += (val1 - val2) ** 2 * distances[row1, row2] = d * if not two_tables: # <<<<<<<<<<<<<< @@ -3714,7 +4074,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma */ } - /* "Orange/distance/_distance.pyx":111 + /* "Orange/distance/_distance.pyx":109 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -3726,7 +4086,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma } } - /* "Orange/distance/_distance.pyx":108 + /* "Orange/distance/_distance.pyx":106 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * with nogil: # <<<<<<<<<<<<<< @@ -3736,6 +4096,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -3744,7 +4105,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma } } - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":92 * * * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< @@ -3783,7 +4144,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma return __pyx_r; } -/* "Orange/distance/_distance.pyx":129 +/* "Orange/distance/_distance.pyx":127 * * * def fix_euclidean_cols( # <<<<<<<<<<<<<< @@ -3792,10 +4153,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_4fix_euclidean_rows_norma */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_cols[] = "fix_euclidean_cols(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_cols = {"fix_euclidean_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_6fix_euclidean_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols[] = "fix_euclidean_cols(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols = {"fix_euclidean_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x = 0; __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; @@ -3811,9 +4172,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObj const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { 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; } @@ -3822,24 +4187,27 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObj case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 1); __PYX_ERR(0, 129, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 1); __PYX_ERR(0, 127, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 2); __PYX_ERR(0, 129, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 2); __PYX_ERR(0, 127, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 3); __PYX_ERR(0, 129, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, 3); __PYX_ERR(0, 127, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols") < 0)) __PYX_ERR(0, 129, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols") < 0)) __PYX_ERR(0, 127, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -3851,20 +4219,20 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObj } __pyx_v_distances = ((PyArrayObject *)values[0]); __pyx_v_x = ((PyArrayObject *)values[1]); - __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 132, __pyx_L3_error) - __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 133, __pyx_L3_error) + __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 130, __pyx_L3_error) + __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 131, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 129, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 127, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 130, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 131, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 128, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); /* function exit code */ goto __pyx_L0; @@ -3875,7 +4243,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_7fix_euclidean_cols(PyObj return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, __Pyx_memviewslice __pyx_v_means, __Pyx_memviewslice __pyx_v_vars) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -3930,16 +4298,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 129, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 127, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 129, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 127, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":138 + /* "Orange/distance/_distance.pyx":136 * double val1, val2, d * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -3951,7 +4319,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":139 + /* "Orange/distance/_distance.pyx":137 * * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: # <<<<<<<<<<<<<< @@ -3962,10 +4330,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":140 + /* "Orange/distance/_distance.pyx":138 * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -3976,7 +4345,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_col1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":141 + /* "Orange/distance/_distance.pyx":139 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -3987,7 +4356,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_col2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":142 + /* "Orange/distance/_distance.pyx":140 * for col1 in range(n_cols): * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< @@ -3999,7 +4368,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":143 + /* "Orange/distance/_distance.pyx":141 * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): * d = 0 # <<<<<<<<<<<<<< @@ -4008,7 +4377,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":144 + /* "Orange/distance/_distance.pyx":142 * if npy_isnan(distances[col1, col2]): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -4019,7 +4388,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_row = __pyx_t_11; - /* "Orange/distance/_distance.pyx":145 + /* "Orange/distance/_distance.pyx":143 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -4035,7 +4404,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":146 + /* "Orange/distance/_distance.pyx":144 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4045,7 +4414,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":147 + /* "Orange/distance/_distance.pyx":145 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4055,7 +4424,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":148 + /* "Orange/distance/_distance.pyx":146 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -4065,7 +4434,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_18 = __pyx_v_col1; __pyx_t_19 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":149 + /* "Orange/distance/_distance.pyx":147 * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ * + (means[col1] - means[col2]) ** 2 # <<<<<<<<<<<<<< @@ -4075,7 +4444,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_20 = __pyx_v_col1; __pyx_t_21 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":148 + /* "Orange/distance/_distance.pyx":146 * if npy_isnan(val1): * if npy_isnan(val2): * d += vars[col1] + vars[col2] \ # <<<<<<<<<<<<<< @@ -4084,7 +4453,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO */ __pyx_v_d = (__pyx_v_d + (((*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_18 * __pyx_v_vars.strides[0]) ))) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_19 * __pyx_v_vars.strides[0]) )))) + pow(((*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_20 * __pyx_v_means.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_21 * __pyx_v_means.strides[0]) )))), 2.0))); - /* "Orange/distance/_distance.pyx":147 + /* "Orange/distance/_distance.pyx":145 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4094,7 +4463,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":151 + /* "Orange/distance/_distance.pyx":149 * + (means[col1] - means[col2]) ** 2 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] # <<<<<<<<<<<<<< @@ -4108,7 +4477,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO } __pyx_L14:; - /* "Orange/distance/_distance.pyx":146 + /* "Orange/distance/_distance.pyx":144 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4118,7 +4487,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":152 + /* "Orange/distance/_distance.pyx":150 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4128,7 +4497,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":153 + /* "Orange/distance/_distance.pyx":151 * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): * d += (val1 - means[col2]) ** 2 + vars[col2] # <<<<<<<<<<<<<< @@ -4139,7 +4508,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_25 = __pyx_v_col2; __pyx_v_d = (__pyx_v_d + (pow((__pyx_v_val1 - (*((double *) ( /* dim=0 */ (__pyx_v_means.data + __pyx_t_24 * __pyx_v_means.strides[0]) )))), 2.0) + (*((double *) ( /* dim=0 */ (__pyx_v_vars.data + __pyx_t_25 * __pyx_v_vars.strides[0]) ))))); - /* "Orange/distance/_distance.pyx":152 + /* "Orange/distance/_distance.pyx":150 * else: * d += (val2 - means[col1]) ** 2 + vars[col1] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4149,7 +4518,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":155 + /* "Orange/distance/_distance.pyx":153 * d += (val1 - means[col2]) ** 2 + vars[col2] * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -4162,7 +4531,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_L13:; } - /* "Orange/distance/_distance.pyx":156 + /* "Orange/distance/_distance.pyx":154 * else: * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -4176,7 +4545,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO __pyx_t_29 = __pyx_v_col1; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":142 + /* "Orange/distance/_distance.pyx":140 * for col1 in range(n_cols): * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< @@ -4188,7 +4557,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO } } - /* "Orange/distance/_distance.pyx":139 + /* "Orange/distance/_distance.pyx":137 * * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: # <<<<<<<<<<<<<< @@ -4198,6 +4567,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -4206,7 +4576,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO } } - /* "Orange/distance/_distance.pyx":129 + /* "Orange/distance/_distance.pyx":127 * * * def fix_euclidean_cols( # <<<<<<<<<<<<<< @@ -4239,7 +4609,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO return __pyx_r; } -/* "Orange/distance/_distance.pyx":159 +/* "Orange/distance/_distance.pyx":157 * * * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< @@ -4248,10 +4618,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_6fix_euclidean_cols(CYTHO */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized = {"fix_euclidean_cols_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_10fix_euclidean_cols_normalized[] = "fix_euclidean_cols_normalized(ndarray distances, ndarray x, __Pyx_memviewslice means, __Pyx_memviewslice vars)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11fix_euclidean_cols_normalized = {"fix_euclidean_cols_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11fix_euclidean_cols_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10fix_euclidean_cols_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_11fix_euclidean_cols_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x = 0; CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means = { 0, 0, { 0 }, { 0 }, { 0 } }; @@ -4267,9 +4637,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_norma const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { 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; } @@ -4278,24 +4652,27 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_norma case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 1); __PYX_ERR(0, 159, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 1); __PYX_ERR(0, 157, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 2); __PYX_ERR(0, 159, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 2); __PYX_ERR(0, 157, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vars)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 3); __PYX_ERR(0, 159, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, 3); __PYX_ERR(0, 157, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols_normalized") < 0)) __PYX_ERR(0, 159, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_euclidean_cols_normalized") < 0)) __PYX_ERR(0, 157, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -4307,20 +4684,20 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_norma } __pyx_v_distances = ((PyArrayObject *)values[0]); __pyx_v_x = ((PyArrayObject *)values[1]); - __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 162, __pyx_L3_error) - __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 163, __pyx_L3_error) + __pyx_v_means = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2]); if (unlikely(!__pyx_v_means.memview)) __PYX_ERR(0, 160, __pyx_L3_error) + __pyx_v_vars = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[3]); if (unlikely(!__pyx_v_vars.memview)) __PYX_ERR(0, 161, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 159, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_euclidean_cols_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 157, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_euclidean_cols_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 160, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 161, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 158, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10fix_euclidean_cols_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x, __pyx_v_means, __pyx_v_vars); /* function exit code */ goto __pyx_L0; @@ -4331,7 +4708,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_9fix_euclidean_cols_norma return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_10fix_euclidean_cols_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_means, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_vars) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -4378,16 +4755,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 159, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 157, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 159, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 157, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":168 + /* "Orange/distance/_distance.pyx":166 * double val1, val2, d * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -4399,7 +4776,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":169 + /* "Orange/distance/_distance.pyx":167 * * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: # <<<<<<<<<<<<<< @@ -4410,10 +4787,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":170 + /* "Orange/distance/_distance.pyx":168 * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -4424,7 +4802,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_col1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":171 + /* "Orange/distance/_distance.pyx":169 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -4435,7 +4813,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_col2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":172 + /* "Orange/distance/_distance.pyx":170 * for col1 in range(n_cols): * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< @@ -4447,7 +4825,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":173 + /* "Orange/distance/_distance.pyx":171 * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): * d = 0 # <<<<<<<<<<<<<< @@ -4456,7 +4834,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":174 + /* "Orange/distance/_distance.pyx":172 * if npy_isnan(distances[col1, col2]): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -4467,7 +4845,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_row = __pyx_t_11; - /* "Orange/distance/_distance.pyx":175 + /* "Orange/distance/_distance.pyx":173 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -4483,7 +4861,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":176 + /* "Orange/distance/_distance.pyx":174 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4493,7 +4871,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":177 + /* "Orange/distance/_distance.pyx":175 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4503,7 +4881,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":178 + /* "Orange/distance/_distance.pyx":176 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -4512,7 +4890,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":177 + /* "Orange/distance/_distance.pyx":175 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4522,7 +4900,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":180 + /* "Orange/distance/_distance.pyx":178 * d += 1 * else: * d += val2 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -4534,7 +4912,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma } __pyx_L14:; - /* "Orange/distance/_distance.pyx":176 + /* "Orange/distance/_distance.pyx":174 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -4544,7 +4922,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":181 + /* "Orange/distance/_distance.pyx":179 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4554,7 +4932,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":182 + /* "Orange/distance/_distance.pyx":180 * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): * d += val1 ** 2 + 0.5 # <<<<<<<<<<<<<< @@ -4563,7 +4941,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma */ __pyx_v_d = (__pyx_v_d + (pow(__pyx_v_val1, 2.0) + 0.5)); - /* "Orange/distance/_distance.pyx":181 + /* "Orange/distance/_distance.pyx":179 * else: * d += val2 ** 2 + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -4573,7 +4951,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":184 + /* "Orange/distance/_distance.pyx":182 * d += val1 ** 2 + 0.5 * else: * d += (val1 - val2) ** 2 # <<<<<<<<<<<<<< @@ -4586,7 +4964,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_L13:; } - /* "Orange/distance/_distance.pyx":185 + /* "Orange/distance/_distance.pyx":183 * else: * d += (val1 - val2) ** 2 * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -4600,7 +4978,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma __pyx_t_21 = __pyx_v_col1; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":172 + /* "Orange/distance/_distance.pyx":170 * for col1 in range(n_cols): * for col2 in range(col1): * if npy_isnan(distances[col1, col2]): # <<<<<<<<<<<<<< @@ -4612,7 +4990,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma } } - /* "Orange/distance/_distance.pyx":169 + /* "Orange/distance/_distance.pyx":167 * * n_rows, n_cols = x.shape[0], x.shape[1] * with nogil: # <<<<<<<<<<<<<< @@ -4622,6 +5000,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -4630,7 +5009,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma } } - /* "Orange/distance/_distance.pyx":159 + /* "Orange/distance/_distance.pyx":157 * * * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< @@ -4663,7 +5042,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma return __pyx_r; } -/* "Orange/distance/_distance.pyx":188 +/* "Orange/distance/_distance.pyx":186 * * * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -4672,10 +5051,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_8fix_euclidean_cols_norma */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows_cont[] = "manhattan_rows_cont(ndarray x1, ndarray x2, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows_cont = {"manhattan_rows_cont", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_10manhattan_rows_cont}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_12manhattan_rows_cont[] = "manhattan_rows_cont(ndarray x1, ndarray x2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13manhattan_rows_cont = {"manhattan_rows_cont", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13manhattan_rows_cont, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12manhattan_rows_cont}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_13manhattan_rows_cont(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; char __pyx_v_two_tables; @@ -4690,8 +5069,11 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyO const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } @@ -4700,19 +5082,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyO case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 1); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 1); __PYX_ERR(0, 186, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 2); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, 2); __PYX_ERR(0, 186, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows_cont") < 0)) __PYX_ERR(0, 188, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_rows_cont") < 0)) __PYX_ERR(0, 186, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -4723,19 +5107,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyO } __pyx_v_x1 = ((PyArrayObject *)values[0]); __pyx_v_x2 = ((PyArrayObject *)values[1]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[2]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_rows_cont", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 186, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_rows_cont", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 188, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 189, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 186, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12manhattan_rows_cont(__pyx_self, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -4746,7 +5130,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_11manhattan_rows_cont(PyO return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_12manhattan_rows_cont(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -4785,8 +5169,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; - int __pyx_t_23; - __Pyx_memviewslice __pyx_t_24 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannySetupContext("manhattan_rows_cont", 0); __pyx_pybuffer_distances.pybuffer.buf = NULL; __pyx_pybuffer_distances.refcount = 0; @@ -4802,16 +5184,16 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 186, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 186, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":196 + /* "Orange/distance/_distance.pyx":194 * np.ndarray[np.float64_t, ndim=2] distances * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -4823,7 +5205,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":197 + /* "Orange/distance/_distance.pyx":195 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -4832,23 +5214,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":198 + /* "Orange/distance/_distance.pyx":196 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -4856,20 +5238,20 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 198, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 198, __pyx_L1_error) + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 196, __pyx_L1_error) __pyx_t_7 = ((PyArrayObject *)__pyx_t_3); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -4885,13 +5267,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT } } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) + if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 196, __pyx_L1_error) } __pyx_t_7 = 0; __pyx_v_distances = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; - /* "Orange/distance/_distance.pyx":199 + /* "Orange/distance/_distance.pyx":197 * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -4902,10 +5284,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":200 + /* "Orange/distance/_distance.pyx":198 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -4916,7 +5299,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_8; __pyx_t_12+=1) { __pyx_v_row1 = __pyx_t_12; - /* "Orange/distance/_distance.pyx":201 + /* "Orange/distance/_distance.pyx":199 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -4931,7 +5314,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_row2 = __pyx_t_14; - /* "Orange/distance/_distance.pyx":202 + /* "Orange/distance/_distance.pyx":200 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * d = 0 # <<<<<<<<<<<<<< @@ -4940,7 +5323,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":203 + /* "Orange/distance/_distance.pyx":201 * for row2 in range(n_rows2 if two_tables else row1): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -4951,12 +5334,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_col = __pyx_t_16; - /* "Orange/distance/_distance.pyx":204 + /* "Orange/distance/_distance.pyx":202 * d = 0 * for col in range(n_cols): * d += fabs(x1[row1, col] - x2[row2, col]) # <<<<<<<<<<<<<< * distances[row1, row2] = d - * # TODO: Do this only at the end, not after each function + * return distances */ __pyx_t_17 = __pyx_v_row1; __pyx_t_18 = __pyx_v_col; @@ -4965,12 +5348,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT __pyx_v_d = (__pyx_v_d + fabs(((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_x1.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_x1.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_x2.diminfo[1].strides))))); } - /* "Orange/distance/_distance.pyx":205 + /* "Orange/distance/_distance.pyx":203 * for col in range(n_cols): * d += fabs(x1[row1, col] - x2[row2, col]) * distances[row1, row2] = d # <<<<<<<<<<<<<< - * # TODO: Do this only at the end, not after each function - * if not two_tables: + * return distances + * */ __pyx_t_21 = __pyx_v_row1; __pyx_t_22 = __pyx_v_row2; @@ -4979,7 +5362,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT } } - /* "Orange/distance/_distance.pyx":199 + /* "Orange/distance/_distance.pyx":197 * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -4989,6 +5372,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -4997,40 +5381,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT } } - /* "Orange/distance/_distance.pyx":207 - * distances[row1, row2] = d - * # TODO: Do this only at the end, not after each function - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_23 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_23) { - - /* "Orange/distance/_distance.pyx":208 - * # TODO: Do this only at the end, not after each function - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_24 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); - if (unlikely(!__pyx_t_24.memview)) __PYX_ERR(0, 208, __pyx_L1_error) - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_24); - __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1); - - /* "Orange/distance/_distance.pyx":207 + /* "Orange/distance/_distance.pyx":204 + * d += fabs(x1[row1, col] - x2[row2, col]) * distances[row1, row2] = d - * # TODO: Do this only at the end, not after each function - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":209 - * if not two_tables: - * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, @@ -5040,7 +5393,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":186 * * * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< @@ -5054,7 +5407,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -5077,7 +5429,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT return __pyx_r; } -/* "Orange/distance/_distance.pyx":211 +/* "Orange/distance/_distance.pyx":206 * return distances * * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< @@ -5086,10 +5438,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_10manhattan_rows_cont(CYT */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_12fix_manhattan_rows[] = "fix_manhattan_rows(ndarray distances, ndarray x1, ndarray x2, ndarray medians, ndarray mads, ndarray dist_missing2_cont, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_13fix_manhattan_rows = {"fix_manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_12fix_manhattan_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows[] = "fix_manhattan_rows(ndarray distances, ndarray x1, ndarray x2, ndarray medians, ndarray mads, ndarray dist_missing2_cont, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows = {"fix_manhattan_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; @@ -5108,12 +5460,19 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyOb const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + CYTHON_FALLTHROUGH; 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; } @@ -5122,39 +5481,45 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyOb case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 1); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 1); __PYX_ERR(0, 206, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 2); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 2); __PYX_ERR(0, 206, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_medians)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 3); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 3); __PYX_ERR(0, 206, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mads)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 4); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 4); __PYX_ERR(0, 206, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist_missing2_cont)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 5); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 5); __PYX_ERR(0, 206, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 6); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, 6); __PYX_ERR(0, 206, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows") < 0)) __PYX_ERR(0, 211, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows") < 0)) __PYX_ERR(0, 206, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { goto __pyx_L5_argtuple_error; @@ -5173,23 +5538,23 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyOb __pyx_v_medians = ((PyArrayObject *)values[3]); __pyx_v_mads = ((PyArrayObject *)values[4]); __pyx_v_dist_missing2_cont = ((PyArrayObject *)values[5]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[6]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 212, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 206, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 211, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 212, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 213, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 214, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 215, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2_cont), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2_cont", 0))) __PYX_ERR(0, 216, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_medians, __pyx_v_mads, __pyx_v_dist_missing2_cont, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 206, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 207, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 208, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 209, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 210, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dist_missing2_cont), __pyx_ptype_5numpy_ndarray, 1, "dist_missing2_cont", 0))) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_medians, __pyx_v_mads, __pyx_v_dist_missing2_cont, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -5200,7 +5565,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_13fix_manhattan_rows(PyOb return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, PyArrayObject *__pyx_v_dist_missing2_cont, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -5248,7 +5613,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; Py_ssize_t __pyx_t_24; - __Pyx_memviewslice __pyx_t_25 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannySetupContext("fix_manhattan_rows", 0); __pyx_pybuffer_distances.pybuffer.buf = NULL; __pyx_pybuffer_distances.refcount = 0; @@ -5276,36 +5640,36 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_pybuffernd_dist_missing2_cont.rcbuffer = &__pyx_pybuffer_dist_missing2_cont; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_medians.diminfo[0].strides = __pyx_pybuffernd_medians.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_medians.diminfo[0].shape = __pyx_pybuffernd_medians.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_mads.diminfo[0].strides = __pyx_pybuffernd_mads.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mads.diminfo[0].shape = __pyx_pybuffernd_mads.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2_cont, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer, (PyObject*)__pyx_v_dist_missing2_cont, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 206, __pyx_L1_error) } __pyx_pybuffernd_dist_missing2_cont.diminfo[0].strides = __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dist_missing2_cont.diminfo[0].shape = __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":222 + /* "Orange/distance/_distance.pyx":217 * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -5317,7 +5681,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":223 + /* "Orange/distance/_distance.pyx":218 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 # <<<<<<<<<<<<<< @@ -5331,7 +5695,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH } __pyx_v_n_rows2 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":224 + /* "Orange/distance/_distance.pyx":219 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< @@ -5342,10 +5706,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":225 + /* "Orange/distance/_distance.pyx":220 * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -5356,7 +5721,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":226 + /* "Orange/distance/_distance.pyx":221 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -5371,7 +5736,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":227 + /* "Orange/distance/_distance.pyx":222 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -5383,7 +5748,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":228 + /* "Orange/distance/_distance.pyx":223 * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): * d = 0 # <<<<<<<<<<<<<< @@ -5392,7 +5757,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":229 + /* "Orange/distance/_distance.pyx":224 * if npy_isnan(distances[row1, row2]): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -5403,7 +5768,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":230 + /* "Orange/distance/_distance.pyx":225 * d = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -5419,7 +5784,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":226 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5429,7 +5794,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":227 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5439,7 +5804,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":233 + /* "Orange/distance/_distance.pyx":228 * if npy_isnan(val1): * if npy_isnan(val2): * d += dist_missing2_cont[col] # <<<<<<<<<<<<<< @@ -5449,7 +5814,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_18 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_dist_missing2_cont.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dist_missing2_cont.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":232 + /* "Orange/distance/_distance.pyx":227 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5459,7 +5824,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":235 + /* "Orange/distance/_distance.pyx":230 * d += dist_missing2_cont[col] * else: * d += fabs(val2 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -5473,7 +5838,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH } __pyx_L14:; - /* "Orange/distance/_distance.pyx":231 + /* "Orange/distance/_distance.pyx":226 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5483,7 +5848,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":231 * else: * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5493,7 +5858,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":237 + /* "Orange/distance/_distance.pyx":232 * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): * d += fabs(val1 - medians[col]) + mads[col] # <<<<<<<<<<<<<< @@ -5504,7 +5869,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_t_22 = __pyx_v_col; __pyx_v_d = (__pyx_v_d + (fabs((__pyx_v_val1 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_medians.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_medians.diminfo[0].strides)))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_mads.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_mads.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":236 + /* "Orange/distance/_distance.pyx":231 * else: * d += fabs(val2 - medians[col]) + mads[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5514,12 +5879,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":239 + /* "Orange/distance/_distance.pyx":234 * d += fabs(val1 - medians[col]) + mads[col] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< * distances[row1, row2] = d - * if not two_tables: + * return distances */ /*else*/ { __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); @@ -5527,18 +5892,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_L13:; } - /* "Orange/distance/_distance.pyx":240 + /* "Orange/distance/_distance.pyx":235 * else: * d += fabs(val1 - val2) * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) + * return distances + * */ __pyx_t_23 = __pyx_v_row1; __pyx_t_24 = __pyx_v_row2; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":227 + /* "Orange/distance/_distance.pyx":222 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -5550,7 +5915,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH } } - /* "Orange/distance/_distance.pyx":224 + /* "Orange/distance/_distance.pyx":219 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< @@ -5560,6 +5925,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -5568,40 +5934,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH } } - /* "Orange/distance/_distance.pyx":241 - * d += fabs(val1 - val2) - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_9) { - - /* "Orange/distance/_distance.pyx":242 - * distances[row1, row2] = d - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); - if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 242, __pyx_L1_error) - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_25); - __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); - - /* "Orange/distance/_distance.pyx":241 + /* "Orange/distance/_distance.pyx":236 * d += fabs(val1 - val2) * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":243 - * if not two_tables: - * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * @@ -5611,7 +5946,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":206 * return distances * * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< @@ -5621,7 +5956,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH /* function exit code */ __pyx_L1_error:; - __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -5649,7 +5983,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH return __pyx_r; } -/* "Orange/distance/_distance.pyx":246 +/* "Orange/distance/_distance.pyx":239 * * * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< @@ -5658,10 +5992,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_12fix_manhattan_rows(CYTH */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized[] = "fix_manhattan_rows_normalized(ndarray distances, ndarray x1, ndarray x2, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized = {"fix_manhattan_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_16fix_manhattan_rows_normalized[] = "fix_manhattan_rows_normalized(ndarray distances, ndarray x1, ndarray x2, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17fix_manhattan_rows_normalized = {"fix_manhattan_rows_normalized", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17fix_manhattan_rows_normalized, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16fix_manhattan_rows_normalized}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_17fix_manhattan_rows_normalized(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_distances = 0; PyArrayObject *__pyx_v_x1 = 0; PyArrayObject *__pyx_v_x2 = 0; @@ -5677,9 +6011,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_norm const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { 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; } @@ -5688,24 +6026,27 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_norm case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 1); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 1); __PYX_ERR(0, 239, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 2); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 2); __PYX_ERR(0, 239, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 3); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, 3); __PYX_ERR(0, 239, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows_normalized") < 0)) __PYX_ERR(0, 246, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fix_manhattan_rows_normalized") < 0)) __PYX_ERR(0, 239, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -5718,20 +6059,20 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_norm __pyx_v_distances = ((PyArrayObject *)values[0]); __pyx_v_x1 = ((PyArrayObject *)values[1]); __pyx_v_x2 = ((PyArrayObject *)values[2]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 249, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fix_manhattan_rows_normalized", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 239, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.fix_manhattan_rows_normalized", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 246, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 247, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 248, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distances), __pyx_ptype_5numpy_ndarray, 1, "distances", 0))) __PYX_ERR(0, 239, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 240, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 241, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16fix_manhattan_rows_normalized(__pyx_self, __pyx_v_distances, __pyx_v_x1, __pyx_v_x2, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -5742,7 +6083,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_15fix_manhattan_rows_norm return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_16fix_manhattan_rows_normalized(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_distances, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -5779,7 +6120,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_t_5numpy_float64_t __pyx_t_17; Py_ssize_t __pyx_t_18; Py_ssize_t __pyx_t_19; - __Pyx_memviewslice __pyx_t_20 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannySetupContext("fix_manhattan_rows_normalized", 0); __pyx_pybuffer_distances.pybuffer.buf = NULL; __pyx_pybuffer_distances.refcount = 0; @@ -5795,21 +6135,21 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_distances.rcbuffer->pybuffer, (PyObject*)__pyx_v_distances, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 239, __pyx_L1_error) } __pyx_pybuffernd_distances.diminfo[0].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_distances.diminfo[0].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_distances.diminfo[1].strides = __pyx_pybuffernd_distances.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_distances.diminfo[1].shape = __pyx_pybuffernd_distances.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 239, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 246, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 239, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":254 + /* "Orange/distance/_distance.pyx":247 * double val1, val2, d * * n_rows1, n_cols = x1.shape[0], x1.shape[1] # <<<<<<<<<<<<<< @@ -5821,7 +6161,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":255 + /* "Orange/distance/_distance.pyx":248 * * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 # <<<<<<<<<<<<<< @@ -5835,7 +6175,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm } __pyx_v_n_rows2 = __pyx_t_2; - /* "Orange/distance/_distance.pyx":256 + /* "Orange/distance/_distance.pyx":249 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< @@ -5846,10 +6186,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":257 + /* "Orange/distance/_distance.pyx":250 * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -5860,7 +6201,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_row1 = __pyx_t_4; - /* "Orange/distance/_distance.pyx":258 + /* "Orange/distance/_distance.pyx":251 * with nogil: * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -5875,7 +6216,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_row2 = __pyx_t_6; - /* "Orange/distance/_distance.pyx":259 + /* "Orange/distance/_distance.pyx":252 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -5887,7 +6228,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_t_9 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_distances.diminfo[1].strides))) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":260 + /* "Orange/distance/_distance.pyx":253 * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): * d = 0 # <<<<<<<<<<<<<< @@ -5896,7 +6237,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":261 + /* "Orange/distance/_distance.pyx":254 * if npy_isnan(distances[row1, row2]): * d = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -5907,7 +6248,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col = __pyx_t_11; - /* "Orange/distance/_distance.pyx":262 + /* "Orange/distance/_distance.pyx":255 * d = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -5923,7 +6264,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_v_val1 = __pyx_t_14; __pyx_v_val2 = __pyx_t_17; - /* "Orange/distance/_distance.pyx":263 + /* "Orange/distance/_distance.pyx":256 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5933,7 +6274,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_t_9 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":264 + /* "Orange/distance/_distance.pyx":257 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5943,7 +6284,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":265 + /* "Orange/distance/_distance.pyx":258 * if npy_isnan(val1): * if npy_isnan(val2): * d += 1 # <<<<<<<<<<<<<< @@ -5952,7 +6293,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":264 + /* "Orange/distance/_distance.pyx":257 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5962,7 +6303,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":267 + /* "Orange/distance/_distance.pyx":260 * d += 1 * else: * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< @@ -5974,7 +6315,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm } __pyx_L14:; - /* "Orange/distance/_distance.pyx":263 + /* "Orange/distance/_distance.pyx":256 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -5984,7 +6325,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":261 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -5994,7 +6335,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_t_9 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_9) { - /* "Orange/distance/_distance.pyx":269 + /* "Orange/distance/_distance.pyx":262 * d += fabs(val2) + 0.5 * elif npy_isnan(val2): * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< @@ -6003,7 +6344,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm */ __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":268 + /* "Orange/distance/_distance.pyx":261 * else: * d += fabs(val2) + 0.5 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6013,12 +6354,12 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":271 + /* "Orange/distance/_distance.pyx":264 * d += fabs(val1) + 0.5 * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< * distances[row1, row2] = d - * if not two_tables: + * return distances */ /*else*/ { __pyx_v_d = (__pyx_v_d + fabs((__pyx_v_val1 - __pyx_v_val2))); @@ -6026,18 +6367,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_L13:; } - /* "Orange/distance/_distance.pyx":272 + /* "Orange/distance/_distance.pyx":265 * else: * d += fabs(val1 - val2) * distances[row1, row2] = d # <<<<<<<<<<<<<< - * if not two_tables: - * _lower_to_symmetric(distances) + * return distances + * */ __pyx_t_18 = __pyx_v_row1; __pyx_t_19 = __pyx_v_row2; *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_distances.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_distances.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_distances.diminfo[1].strides) = __pyx_v_d; - /* "Orange/distance/_distance.pyx":259 + /* "Orange/distance/_distance.pyx":252 * for row1 in range(n_rows1): * for row2 in range(n_rows2 if two_tables else row1): * if npy_isnan(distances[row1, row2]): # <<<<<<<<<<<<<< @@ -6049,7 +6390,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm } } - /* "Orange/distance/_distance.pyx":256 + /* "Orange/distance/_distance.pyx":249 * n_rows1, n_cols = x1.shape[0], x1.shape[1] * n_rows2 = x2.shape[0] if two_tables else 0 * with nogil: # <<<<<<<<<<<<<< @@ -6059,6 +6400,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -6067,40 +6409,9 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm } } - /* "Orange/distance/_distance.pyx":273 - * d += fabs(val1 - val2) - * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - __pyx_t_9 = ((!(__pyx_v_two_tables != 0)) != 0); - if (__pyx_t_9) { - - /* "Orange/distance/_distance.pyx":274 - * distances[row1, row2] = d - * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< - * return distances - * - */ - __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(((PyObject *)__pyx_v_distances)); - if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 274, __pyx_L1_error) - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_t_20); - __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); - - /* "Orange/distance/_distance.pyx":273 + /* "Orange/distance/_distance.pyx":266 * d += fabs(val1 - val2) * distances[row1, row2] = d - * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) - * return distances - */ - } - - /* "Orange/distance/_distance.pyx":275 - * if not two_tables: - * _lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * @@ -6110,7 +6421,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm __pyx_r = ((PyObject *)__pyx_v_distances); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":246 + /* "Orange/distance/_distance.pyx":239 * * * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< @@ -6120,7 +6431,6 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm /* function exit code */ __pyx_L1_error:; - __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -6142,7 +6452,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm return __pyx_r; } -/* "Orange/distance/_distance.pyx":278 +/* "Orange/distance/_distance.pyx":269 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< @@ -6151,10 +6461,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_14fix_manhattan_rows_norm */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_16manhattan_cols[] = "manhattan_cols(ndarray x, ndarray medians, ndarray mads, char normalize)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_17manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_16manhattan_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_18manhattan_cols[] = "manhattan_cols(ndarray x, ndarray medians, ndarray mads, char normalize)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_19manhattan_cols = {"manhattan_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_19manhattan_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_18manhattan_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_19manhattan_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_x = 0; PyArrayObject *__pyx_v_medians = 0; PyArrayObject *__pyx_v_mads = 0; @@ -6170,9 +6480,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { 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; } @@ -6181,24 +6495,27 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_medians)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 1); __PYX_ERR(0, 278, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 1); __PYX_ERR(0, 269, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mads)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 2); __PYX_ERR(0, 278, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 2); __PYX_ERR(0, 269, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_normalize)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 3); __PYX_ERR(0, 278, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, 3); __PYX_ERR(0, 269, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 278, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "manhattan_cols") < 0)) __PYX_ERR(0, 269, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6211,20 +6528,20 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject __pyx_v_x = ((PyArrayObject *)values[0]); __pyx_v_medians = ((PyArrayObject *)values[1]); __pyx_v_mads = ((PyArrayObject *)values[2]); - __pyx_v_normalize = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_normalize == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 281, __pyx_L3_error) + __pyx_v_normalize = __Pyx_PyInt_As_char(values[3]); if (unlikely((__pyx_v_normalize == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 272, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 278, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("manhattan_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 269, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.manhattan_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 278, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 279, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 280, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_medians, __pyx_v_mads, __pyx_v_normalize); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 269, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_medians), __pyx_ptype_5numpy_ndarray, 1, "medians", 0))) __PYX_ERR(0, 270, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mads), __pyx_ptype_5numpy_ndarray, 1, "mads", 0))) __PYX_ERR(0, 271, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_18manhattan_cols(__pyx_self, __pyx_v_x, __pyx_v_medians, __pyx_v_mads, __pyx_v_normalize); /* function exit code */ goto __pyx_L0; @@ -6235,7 +6552,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_17manhattan_cols(PyObject return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_18manhattan_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_medians, PyArrayObject *__pyx_v_mads, char __pyx_v_normalize) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -6300,21 +6617,21 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_pybuffernd_mads.rcbuffer = &__pyx_pybuffer_mads; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 269, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_medians.rcbuffer->pybuffer, (PyObject*)__pyx_v_medians, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 269, __pyx_L1_error) } __pyx_pybuffernd_medians.diminfo[0].strides = __pyx_pybuffernd_medians.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_medians.diminfo[0].shape = __pyx_pybuffernd_medians.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mads.rcbuffer->pybuffer, (PyObject*)__pyx_v_mads, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 269, __pyx_L1_error) } __pyx_pybuffernd_mads.diminfo[0].strides = __pyx_pybuffernd_mads.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mads.diminfo[0].shape = __pyx_pybuffernd_mads.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":287 + /* "Orange/distance/_distance.pyx":278 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -6326,23 +6643,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":288 + /* "Orange/distance/_distance.pyx":279 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -6350,27 +6667,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 288, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); - if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 288, __pyx_L1_error) + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_distances = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":289 + /* "Orange/distance/_distance.pyx":280 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -6381,10 +6698,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":290 + /* "Orange/distance/_distance.pyx":281 * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -6395,7 +6713,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_col1 = __pyx_t_9; - /* "Orange/distance/_distance.pyx":291 + /* "Orange/distance/_distance.pyx":282 * with nogil: * for col1 in range(n_cols): * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -6406,7 +6724,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_col2 = __pyx_t_11; - /* "Orange/distance/_distance.pyx":292 + /* "Orange/distance/_distance.pyx":283 * for col1 in range(n_cols): * for col2 in range(col1): * d = 0 # <<<<<<<<<<<<<< @@ -6415,7 +6733,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U */ __pyx_v_d = 0.0; - /* "Orange/distance/_distance.pyx":293 + /* "Orange/distance/_distance.pyx":284 * for col2 in range(col1): * d = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -6426,7 +6744,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row = __pyx_t_13; - /* "Orange/distance/_distance.pyx":294 + /* "Orange/distance/_distance.pyx":285 * d = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -6442,7 +6760,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_v_val1 = __pyx_t_16; __pyx_v_val2 = __pyx_t_19; - /* "Orange/distance/_distance.pyx":295 + /* "Orange/distance/_distance.pyx":286 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6452,7 +6770,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":296 + /* "Orange/distance/_distance.pyx":287 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6462,7 +6780,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":297 + /* "Orange/distance/_distance.pyx":288 * if npy_isnan(val1): * if npy_isnan(val2): * if normalize: # <<<<<<<<<<<<<< @@ -6472,7 +6790,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (__pyx_v_normalize != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":298 + /* "Orange/distance/_distance.pyx":289 * if npy_isnan(val2): * if normalize: * d += 1 # <<<<<<<<<<<<<< @@ -6481,7 +6799,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U */ __pyx_v_d = (__pyx_v_d + 1.0); - /* "Orange/distance/_distance.pyx":297 + /* "Orange/distance/_distance.pyx":288 * if npy_isnan(val1): * if npy_isnan(val2): * if normalize: # <<<<<<<<<<<<<< @@ -6491,7 +6809,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":300 + /* "Orange/distance/_distance.pyx":291 * d += 1 * else: * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -6502,7 +6820,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_21 = __pyx_v_col1; __pyx_t_22 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":301 + /* "Orange/distance/_distance.pyx":292 * else: * d += mads[col1] + mads[col2] \ * + fabs(medians[col1] - medians[col2]) # <<<<<<<<<<<<<< @@ -6512,7 +6830,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_23 = __pyx_v_col1; __pyx_t_24 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":300 + /* "Orange/distance/_distance.pyx":291 * d += 1 * else: * d += mads[col1] + mads[col2] \ # <<<<<<<<<<<<<< @@ -6523,7 +6841,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U } __pyx_L14:; - /* "Orange/distance/_distance.pyx":296 + /* "Orange/distance/_distance.pyx":287 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6533,7 +6851,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":303 + /* "Orange/distance/_distance.pyx":294 * + fabs(medians[col1] - medians[col2]) * else: * if normalize: # <<<<<<<<<<<<<< @@ -6544,7 +6862,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (__pyx_v_normalize != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":304 + /* "Orange/distance/_distance.pyx":295 * else: * if normalize: * d += fabs(val2) + 0.5 # <<<<<<<<<<<<<< @@ -6553,7 +6871,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U */ __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val2) + 0.5)); - /* "Orange/distance/_distance.pyx":303 + /* "Orange/distance/_distance.pyx":294 * + fabs(medians[col1] - medians[col2]) * else: * if normalize: # <<<<<<<<<<<<<< @@ -6563,7 +6881,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":306 + /* "Orange/distance/_distance.pyx":297 * d += fabs(val2) + 0.5 * else: * d += fabs(val2 - medians[col1]) + mads[col1] # <<<<<<<<<<<<<< @@ -6579,7 +6897,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U } __pyx_L13:; - /* "Orange/distance/_distance.pyx":295 + /* "Orange/distance/_distance.pyx":286 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -6589,7 +6907,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L12; } - /* "Orange/distance/_distance.pyx":308 + /* "Orange/distance/_distance.pyx":299 * d += fabs(val2 - medians[col1]) + mads[col1] * else: * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6600,7 +6918,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":309 + /* "Orange/distance/_distance.pyx":300 * else: * if npy_isnan(val2): * if normalize: # <<<<<<<<<<<<<< @@ -6610,7 +6928,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_t_20 = (__pyx_v_normalize != 0); if (__pyx_t_20) { - /* "Orange/distance/_distance.pyx":310 + /* "Orange/distance/_distance.pyx":301 * if npy_isnan(val2): * if normalize: * d += fabs(val1) + 0.5 # <<<<<<<<<<<<<< @@ -6619,7 +6937,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U */ __pyx_v_d = (__pyx_v_d + (fabs(__pyx_v_val1) + 0.5)); - /* "Orange/distance/_distance.pyx":309 + /* "Orange/distance/_distance.pyx":300 * else: * if npy_isnan(val2): * if normalize: # <<<<<<<<<<<<<< @@ -6629,7 +6947,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L17; } - /* "Orange/distance/_distance.pyx":312 + /* "Orange/distance/_distance.pyx":303 * d += fabs(val1) + 0.5 * else: * d += fabs(val1 - medians[col2]) + mads[col2] # <<<<<<<<<<<<<< @@ -6643,7 +6961,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U } __pyx_L17:; - /* "Orange/distance/_distance.pyx":308 + /* "Orange/distance/_distance.pyx":299 * d += fabs(val2 - medians[col1]) + mads[col1] * else: * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -6653,7 +6971,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U goto __pyx_L16; } - /* "Orange/distance/_distance.pyx":314 + /* "Orange/distance/_distance.pyx":305 * d += fabs(val1 - medians[col2]) + mads[col2] * else: * d += fabs(val1 - val2) # <<<<<<<<<<<<<< @@ -6668,7 +6986,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U __pyx_L12:; } - /* "Orange/distance/_distance.pyx":315 + /* "Orange/distance/_distance.pyx":306 * else: * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d # <<<<<<<<<<<<<< @@ -6685,7 +7003,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U } } - /* "Orange/distance/_distance.pyx":289 + /* "Orange/distance/_distance.pyx":280 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -6695,6 +7013,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -6703,7 +7022,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U } } - /* "Orange/distance/_distance.pyx":316 + /* "Orange/distance/_distance.pyx":307 * d += fabs(val1 - val2) * distances[col1, col2] = distances[col2, col1] = d * return distances # <<<<<<<<<<<<<< @@ -6711,13 +7030,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":269 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< @@ -6754,7 +7073,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U return __pyx_r; } -/* "Orange/distance/_distance.pyx":319 +/* "Orange/distance/_distance.pyx":310 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -6763,15 +7082,15 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_16manhattan_cols(CYTHON_U */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_19p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_18p_nonzero[] = "p_nonzero(ndarray x)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_19p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_19p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_18p_nonzero}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_19p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_20p_nonzero[] = "p_nonzero(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_21p_nonzero = {"p_nonzero", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_21p_nonzero, METH_O, __pyx_doc_6Orange_8distance_9_distance_20p_nonzero}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_21p_nonzero(PyObject *__pyx_self, PyObject *__pyx_v_x) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("p_nonzero (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 319, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_18p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 310, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_20p_nonzero(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ goto __pyx_L0; @@ -6782,7 +7101,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_19p_nonzero(PyObject *__p return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_20p_nonzero(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { int __pyx_v_row; int __pyx_v_nonzeros; int __pyx_v_nonnans; @@ -6803,11 +7122,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 319, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 310, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":324 + /* "Orange/distance/_distance.pyx":315 * double val * * nonzeros = nonnans = 0 # <<<<<<<<<<<<<< @@ -6817,18 +7136,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED __pyx_v_nonzeros = 0; __pyx_v_nonnans = 0; - /* "Orange/distance/_distance.pyx":325 + /* "Orange/distance/_distance.pyx":316 * * nonzeros = nonnans = 0 * for row in range(len(x)): # <<<<<<<<<<<<<< * val = x[row] * if not npy_isnan(val): */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 325, __pyx_L1_error) + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_x)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 316, __pyx_L1_error) for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_row = __pyx_t_2; - /* "Orange/distance/_distance.pyx":326 + /* "Orange/distance/_distance.pyx":317 * nonzeros = nonnans = 0 * for row in range(len(x)): * val = x[row] # <<<<<<<<<<<<<< @@ -6838,7 +7157,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED __pyx_t_3 = __pyx_v_row; __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_x.diminfo[0].strides)); - /* "Orange/distance/_distance.pyx":327 + /* "Orange/distance/_distance.pyx":318 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -6848,7 +7167,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((!(npy_isnan(__pyx_v_val) != 0)) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":328 + /* "Orange/distance/_distance.pyx":319 * val = x[row] * if not npy_isnan(val): * nonnans += 1 # <<<<<<<<<<<<<< @@ -6857,7 +7176,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED */ __pyx_v_nonnans = (__pyx_v_nonnans + 1); - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":320 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -6867,7 +7186,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED __pyx_t_4 = ((__pyx_v_val != 0.0) != 0); if (__pyx_t_4) { - /* "Orange/distance/_distance.pyx":330 + /* "Orange/distance/_distance.pyx":321 * nonnans += 1 * if val != 0: * nonzeros += 1 # <<<<<<<<<<<<<< @@ -6876,7 +7195,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED */ __pyx_v_nonzeros = (__pyx_v_nonzeros + 1); - /* "Orange/distance/_distance.pyx":329 + /* "Orange/distance/_distance.pyx":320 * if not npy_isnan(val): * nonnans += 1 * if val != 0: # <<<<<<<<<<<<<< @@ -6885,7 +7204,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED */ } - /* "Orange/distance/_distance.pyx":327 + /* "Orange/distance/_distance.pyx":318 * for row in range(len(x)): * val = x[row] * if not npy_isnan(val): # <<<<<<<<<<<<<< @@ -6895,7 +7214,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED } } - /* "Orange/distance/_distance.pyx":331 + /* "Orange/distance/_distance.pyx":322 * if val != 0: * nonzeros += 1 * return float(nonzeros) / nonnans # <<<<<<<<<<<<<< @@ -6903,13 +7222,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 331, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_nonzeros) / __pyx_v_nonnans)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":310 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< @@ -6937,7 +7256,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED return __pyx_r; } -/* "Orange/distance/_distance.pyx":333 +/* "Orange/distance/_distance.pyx":324 * return float(nonzeros) / nonnans * * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< @@ -6946,15 +7265,15 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_18p_nonzero(CYTHON_UNUSED */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_21any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_20any_nan_row[] = "any_nan_row(ndarray x)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_21any_nan_row = {"any_nan_row", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_21any_nan_row, METH_O, __pyx_doc_6Orange_8distance_9_distance_20any_nan_row}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_21any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_22any_nan_row[] = "any_nan_row(ndarray x)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_23any_nan_row = {"any_nan_row", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_23any_nan_row, METH_O, __pyx_doc_6Orange_8distance_9_distance_22any_nan_row}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_23any_nan_row(PyObject *__pyx_self, PyObject *__pyx_v_x) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("any_nan_row (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 333, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_20any_nan_row(__pyx_self, ((PyArrayObject *)__pyx_v_x)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_22any_nan_row(__pyx_self, ((PyArrayObject *)__pyx_v_x)); /* function exit code */ goto __pyx_L0; @@ -6965,7 +7284,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_21any_nan_row(PyObject *_ return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_22any_nan_row(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_x) { int __pyx_v_row; int __pyx_v_n_cols; int __pyx_v_n_rows; @@ -7007,11 +7326,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 333, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; - /* "Orange/distance/_distance.pyx":338 + /* "Orange/distance/_distance.pyx":329 * np.ndarray[np.int8_t, ndim=1] flags * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -7023,40 +7342,40 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":339 + /* "Orange/distance/_distance.pyx":330 * * n_rows, n_cols = x.shape[0], x.shape[1] * flags = np.zeros(x.shape[0], dtype=np.int8) # <<<<<<<<<<<<<< * with nogil: * for row in range(n_rows): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_x->dimensions[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_x->dimensions[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 339, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 339, __pyx_L1_error) + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 330, __pyx_L1_error) __pyx_t_8 = ((PyArrayObject *)__pyx_t_7); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7072,13 +7391,13 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS } } __pyx_pybuffernd_flags.diminfo[0].strides = __pyx_pybuffernd_flags.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_flags.diminfo[0].shape = __pyx_pybuffernd_flags.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 339, __pyx_L1_error) + if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 330, __pyx_L1_error) } __pyx_t_8 = 0; __pyx_v_flags = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":331 * n_rows, n_cols = x.shape[0], x.shape[1] * flags = np.zeros(x.shape[0], dtype=np.int8) * with nogil: # <<<<<<<<<<<<<< @@ -7089,10 +7408,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":341 + /* "Orange/distance/_distance.pyx":332 * flags = np.zeros(x.shape[0], dtype=np.int8) * with nogil: * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -7103,7 +7423,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_9; __pyx_t_13+=1) { __pyx_v_row = __pyx_t_13; - /* "Orange/distance/_distance.pyx":342 + /* "Orange/distance/_distance.pyx":333 * with nogil: * for row in range(n_rows): * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -7114,7 +7434,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":343 + /* "Orange/distance/_distance.pyx":334 * for row in range(n_rows): * for col in range(n_cols): * if npy_isnan(x[row, col]): # <<<<<<<<<<<<<< @@ -7126,7 +7446,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS __pyx_t_18 = (npy_isnan((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_x.diminfo[1].strides))) != 0); if (__pyx_t_18) { - /* "Orange/distance/_distance.pyx":344 + /* "Orange/distance/_distance.pyx":335 * for col in range(n_cols): * if npy_isnan(x[row, col]): * flags[row] = 1 # <<<<<<<<<<<<<< @@ -7136,7 +7456,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS __pyx_t_19 = __pyx_v_row; *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_flags.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_flags.diminfo[0].strides) = 1; - /* "Orange/distance/_distance.pyx":345 + /* "Orange/distance/_distance.pyx":336 * if npy_isnan(x[row, col]): * flags[row] = 1 * break # <<<<<<<<<<<<<< @@ -7145,7 +7465,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS */ goto __pyx_L9_break; - /* "Orange/distance/_distance.pyx":343 + /* "Orange/distance/_distance.pyx":334 * for row in range(n_rows): * for col in range(n_cols): * if npy_isnan(x[row, col]): # <<<<<<<<<<<<<< @@ -7158,7 +7478,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":340 + /* "Orange/distance/_distance.pyx":331 * n_rows, n_cols = x.shape[0], x.shape[1] * flags = np.zeros(x.shape[0], dtype=np.int8) * with nogil: # <<<<<<<<<<<<<< @@ -7168,6 +7488,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -7176,7 +7497,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS } } - /* "Orange/distance/_distance.pyx":346 + /* "Orange/distance/_distance.pyx":337 * flags[row] = 1 * break * return flags # <<<<<<<<<<<<<< @@ -7188,7 +7509,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS __pyx_r = ((PyObject *)__pyx_v_flags); goto __pyx_L0; - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":324 * return float(nonzeros) / nonnans * * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< @@ -7223,7 +7544,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS return __pyx_r; } -/* "Orange/distance/_distance.pyx":349 +/* "Orange/distance/_distance.pyx":340 * * * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< @@ -7232,10 +7553,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_20any_nan_row(CYTHON_UNUS */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_22jaccard_rows[] = "jaccard_rows(ndarray nonzeros1, ndarray nonzeros2, ndarray x1, ndarray x2, ndarray nans1, ndarray nans2, ndarray ps, char two_tables)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_23jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_22jaccard_rows}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_24jaccard_rows[] = "jaccard_rows(ndarray nonzeros1, ndarray nonzeros2, ndarray x1, ndarray x2, ndarray nans1, ndarray nans2, ndarray ps, char two_tables)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_25jaccard_rows = {"jaccard_rows", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_25jaccard_rows, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_24jaccard_rows}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_nonzeros1 = 0; PyArrayObject *__pyx_v_nonzeros2 = 0; PyArrayObject *__pyx_v_x1 = 0; @@ -7255,13 +7576,21 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject * const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + CYTHON_FALLTHROUGH; 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; } @@ -7270,44 +7599,51 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject * case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros1)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 1); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 1); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 2); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 2); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 3); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 3); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans1)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 4); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 4); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 5); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 5); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ps)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 6); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 6); __PYX_ERR(0, 340, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_two_tables)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 7); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, 7); __PYX_ERR(0, 340, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 349, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_rows") < 0)) __PYX_ERR(0, 340, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 8) { goto __pyx_L5_argtuple_error; @@ -7328,24 +7664,24 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject * __pyx_v_nans1 = ((PyArrayObject *)values[4]); __pyx_v_nans2 = ((PyArrayObject *)values[5]); __pyx_v_ps = ((PyArrayObject *)values[6]); - __pyx_v_two_tables = __Pyx_PyInt_As_char(values[7]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L3_error) + __pyx_v_two_tables = __Pyx_PyInt_As_char(values[7]); if (unlikely((__pyx_v_two_tables == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_rows", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 340, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_rows", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros1), __pyx_ptype_5numpy_ndarray, 1, "nonzeros1", 0))) __PYX_ERR(0, 349, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros2), __pyx_ptype_5numpy_ndarray, 1, "nonzeros2", 0))) __PYX_ERR(0, 350, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 351, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 352, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans1), __pyx_ptype_5numpy_ndarray, 1, "nans1", 0))) __PYX_ERR(0, 353, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans2), __pyx_ptype_5numpy_ndarray, 1, "nans2", 0))) __PYX_ERR(0, 354, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 355, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(__pyx_self, __pyx_v_nonzeros1, __pyx_v_nonzeros2, __pyx_v_x1, __pyx_v_x2, __pyx_v_nans1, __pyx_v_nans2, __pyx_v_ps, __pyx_v_two_tables); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros1), __pyx_ptype_5numpy_ndarray, 1, "nonzeros1", 0))) __PYX_ERR(0, 340, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros2), __pyx_ptype_5numpy_ndarray, 1, "nonzeros2", 0))) __PYX_ERR(0, 341, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x1), __pyx_ptype_5numpy_ndarray, 1, "x1", 0))) __PYX_ERR(0, 342, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x2), __pyx_ptype_5numpy_ndarray, 1, "x2", 0))) __PYX_ERR(0, 343, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans1), __pyx_ptype_5numpy_ndarray, 1, "nans1", 0))) __PYX_ERR(0, 344, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans2), __pyx_ptype_5numpy_ndarray, 1, "nans2", 0))) __PYX_ERR(0, 345, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_24jaccard_rows(__pyx_self, __pyx_v_nonzeros1, __pyx_v_nonzeros2, __pyx_v_x1, __pyx_v_x2, __pyx_v_nans1, __pyx_v_nans2, __pyx_v_ps, __pyx_v_two_tables); /* function exit code */ goto __pyx_L0; @@ -7356,7 +7692,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_23jaccard_rows(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_rows(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros1, PyArrayObject *__pyx_v_nonzeros2, PyArrayObject *__pyx_v_x1, PyArrayObject *__pyx_v_x2, PyArrayObject *__pyx_v_nans1, PyArrayObject *__pyx_v_nans2, PyArrayObject *__pyx_v_ps, char __pyx_v_two_tables) { int __pyx_v_n_rows1; int __pyx_v_n_rows2; int __pyx_v_n_cols; @@ -7463,41 +7799,41 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_pybuffernd_ps.rcbuffer = &__pyx_pybuffer_ps; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_nonzeros1.diminfo[0].strides = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros1.diminfo[0].shape = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros1.diminfo[1].strides = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros1.diminfo[1].shape = __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_nonzeros2.diminfo[0].strides = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros2.diminfo[0].shape = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros2.diminfo[1].strides = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros2.diminfo[1].shape = __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_v_x1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x1.diminfo[1].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x1.diminfo[1].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_v_x2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x2.diminfo[1].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x2.diminfo[1].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans1.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_nans1.diminfo[0].strides = __pyx_pybuffernd_nans1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans1.diminfo[0].shape = __pyx_pybuffernd_nans1.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans2.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_nans2.diminfo[0].strides = __pyx_pybuffernd_nans2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans2.diminfo[0].shape = __pyx_pybuffernd_nans2.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 349, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_pybuffernd_ps.diminfo[0].strides = __pyx_pybuffernd_ps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ps.diminfo[0].shape = __pyx_pybuffernd_ps.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":363 + /* "Orange/distance/_distance.pyx":354 * double [:, :] distances * * n_rows1, n_cols = x1.shape[0], x2.shape[1] # <<<<<<<<<<<<<< @@ -7509,7 +7845,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_v_n_rows1 = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":364 + /* "Orange/distance/_distance.pyx":355 * * n_rows1, n_cols = x1.shape[0], x2.shape[1] * n_rows2 = x2.shape[0] # <<<<<<<<<<<<<< @@ -7518,23 +7854,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_n_rows2 = (__pyx_v_x2->dimensions[0]); - /* "Orange/distance/_distance.pyx":365 + /* "Orange/distance/_distance.pyx":356 * n_rows1, n_cols = x1.shape[0], x2.shape[1] * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for row1 in range(n_rows1): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_rows1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_rows2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -7542,27 +7878,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 365, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 356, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); - if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 365, __pyx_L1_error) + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_distances = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":366 + /* "Orange/distance/_distance.pyx":357 * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -7573,10 +7909,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":367 + /* "Orange/distance/_distance.pyx":358 * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: * for row1 in range(n_rows1): # <<<<<<<<<<<<<< @@ -7587,7 +7924,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_row1 = __pyx_t_9; - /* "Orange/distance/_distance.pyx":368 + /* "Orange/distance/_distance.pyx":359 * with nogil: * for row1 in range(n_rows1): * if nans1[row1]: # <<<<<<<<<<<<<< @@ -7598,7 +7935,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans1.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_nans1.diminfo[0].strides)) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":369 + /* "Orange/distance/_distance.pyx":360 * for row1 in range(n_rows1): * if nans1[row1]: * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -7613,7 +7950,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":370 + /* "Orange/distance/_distance.pyx":361 * if nans1[row1]: * for row2 in range(n_rows2 if two_tables else row1): * union = intersection = 0 # <<<<<<<<<<<<<< @@ -7623,7 +7960,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_v_union = 0.0; __pyx_v_intersection = 0.0; - /* "Orange/distance/_distance.pyx":371 + /* "Orange/distance/_distance.pyx":362 * for row2 in range(n_rows2 if two_tables else row1): * union = intersection = 0 * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -7634,7 +7971,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":372 + /* "Orange/distance/_distance.pyx":363 * union = intersection = 0 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] # <<<<<<<<<<<<<< @@ -7650,7 +7987,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":373 + /* "Orange/distance/_distance.pyx":364 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7660,7 +7997,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":374 + /* "Orange/distance/_distance.pyx":365 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7670,7 +8007,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":375 + /* "Orange/distance/_distance.pyx":366 * if npy_isnan(val1): * if npy_isnan(val2): * intersection += ps[col] ** 2 # <<<<<<<<<<<<<< @@ -7680,7 +8017,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_22 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + pow((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_ps.diminfo[0].strides)), 2.0)); - /* "Orange/distance/_distance.pyx":376 + /* "Orange/distance/_distance.pyx":367 * if npy_isnan(val2): * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 # <<<<<<<<<<<<<< @@ -7690,7 +8027,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_23 = __pyx_v_col; __pyx_v_union = (__pyx_v_union + (1.0 - pow((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_ps.diminfo[0].strides))), 2.0))); - /* "Orange/distance/_distance.pyx":374 + /* "Orange/distance/_distance.pyx":365 * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7700,7 +8037,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":377 + /* "Orange/distance/_distance.pyx":368 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -7710,7 +8047,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":378 + /* "Orange/distance/_distance.pyx":369 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: * intersection += ps[col] # <<<<<<<<<<<<<< @@ -7720,7 +8057,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_24 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_ps.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":379 + /* "Orange/distance/_distance.pyx":370 * elif val2 != 0: * intersection += ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -7729,7 +8066,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":377 + /* "Orange/distance/_distance.pyx":368 * intersection += ps[col] ** 2 * union += 1 - (1 - ps[col]) ** 2 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -7739,7 +8076,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":381 + /* "Orange/distance/_distance.pyx":372 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -7752,7 +8089,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } __pyx_L14:; - /* "Orange/distance/_distance.pyx":373 + /* "Orange/distance/_distance.pyx":364 * for col in range(n_cols): * val1, val2 = x1[row1, col], x2[row2, col] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -7762,7 +8099,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":373 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7772,7 +8109,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":383 + /* "Orange/distance/_distance.pyx":374 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -7782,7 +8119,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":384 + /* "Orange/distance/_distance.pyx":375 * elif npy_isnan(val2): * if val1 != 0: * intersection += val1 * ps[col] # <<<<<<<<<<<<<< @@ -7792,7 +8129,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_26 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (__pyx_v_val1 * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ps.diminfo[0].strides)))); - /* "Orange/distance/_distance.pyx":385 + /* "Orange/distance/_distance.pyx":376 * if val1 != 0: * intersection += val1 * ps[col] * union += 1 # <<<<<<<<<<<<<< @@ -7801,7 +8138,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":383 + /* "Orange/distance/_distance.pyx":374 * union += ps[col] * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -7811,7 +8148,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":387 + /* "Orange/distance/_distance.pyx":378 * union += 1 * else: * union += ps[col] # <<<<<<<<<<<<<< @@ -7824,7 +8161,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } __pyx_L15:; - /* "Orange/distance/_distance.pyx":382 + /* "Orange/distance/_distance.pyx":373 * else: * union += ps[col] * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -7834,7 +8171,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":389 + /* "Orange/distance/_distance.pyx":380 * union += ps[col] * else: * ival1 = nonzeros1[row1, col] # <<<<<<<<<<<<<< @@ -7846,7 +8183,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_29 = __pyx_v_col; __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":390 + /* "Orange/distance/_distance.pyx":381 * else: * ival1 = nonzeros1[row1, col] * ival2 = nonzeros2[row2, col] # <<<<<<<<<<<<<< @@ -7857,7 +8194,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_31 = __pyx_v_col; __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_nonzeros2.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_nonzeros2.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":391 + /* "Orange/distance/_distance.pyx":382 * ival1 = nonzeros1[row1, col] * ival2 = nonzeros2[row2, col] * union += ival1 | ival2 # <<<<<<<<<<<<<< @@ -7866,7 +8203,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + (__pyx_v_ival1 | __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":392 + /* "Orange/distance/_distance.pyx":383 * ival2 = nonzeros2[row2, col] * union += ival1 | ival2 * intersection += ival1 & ival2 # <<<<<<<<<<<<<< @@ -7878,7 +8215,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_L13:; } - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":384 * union += ival1 | ival2 * intersection += ival1 & ival2 * if union != 0: # <<<<<<<<<<<<<< @@ -7888,7 +8225,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":394 + /* "Orange/distance/_distance.pyx":385 * intersection += ival1 & ival2 * if union != 0: * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< @@ -7899,7 +8236,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_33 = __pyx_v_row2; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_32 * __pyx_v_distances.strides[0]) ) + __pyx_t_33 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":393 + /* "Orange/distance/_distance.pyx":384 * union += ival1 | ival2 * intersection += ival1 & ival2 * if union != 0: # <<<<<<<<<<<<<< @@ -7909,7 +8246,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":368 + /* "Orange/distance/_distance.pyx":359 * with nogil: * for row1 in range(n_rows1): * if nans1[row1]: # <<<<<<<<<<<<<< @@ -7919,7 +8256,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L8; } - /* "Orange/distance/_distance.pyx":396 + /* "Orange/distance/_distance.pyx":387 * distances[row1, row2] = 1 - intersection / union * else: * for row2 in range(n_rows2 if two_tables else row1): # <<<<<<<<<<<<<< @@ -7935,7 +8272,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_row2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":397 + /* "Orange/distance/_distance.pyx":388 * else: * for row2 in range(n_rows2 if two_tables else row1): * union = intersection = 0 # <<<<<<<<<<<<<< @@ -7945,7 +8282,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_v_union = 0.0; __pyx_v_intersection = 0.0; - /* "Orange/distance/_distance.pyx":399 + /* "Orange/distance/_distance.pyx":390 * union = intersection = 0 * # This case is slightly different since val1 can't be nan * if nans2[row2]: # <<<<<<<<<<<<<< @@ -7956,7 +8293,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans2.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_nans2.diminfo[0].strides)) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":400 + /* "Orange/distance/_distance.pyx":391 * # This case is slightly different since val1 can't be nan * if nans2[row2]: * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -7967,7 +8304,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":401 + /* "Orange/distance/_distance.pyx":392 * if nans2[row2]: * for col in range(n_cols): * val2 = x2[row2, col] # <<<<<<<<<<<<<< @@ -7978,7 +8315,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_36 = __pyx_v_col; __pyx_v_val2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_x2.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_x2.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":402 + /* "Orange/distance/_distance.pyx":393 * for col in range(n_cols): * val2 = x2[row2, col] * if nonzeros1[row1, col] != 0: # <<<<<<<<<<<<<< @@ -7990,7 +8327,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)) != 0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":403 + /* "Orange/distance/_distance.pyx":394 * val2 = x2[row2, col] * if nonzeros1[row1, col] != 0: * union += 1 # <<<<<<<<<<<<<< @@ -7999,7 +8336,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":404 + /* "Orange/distance/_distance.pyx":395 * if nonzeros1[row1, col] != 0: * union += 1 * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8009,7 +8346,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":405 + /* "Orange/distance/_distance.pyx":396 * union += 1 * if npy_isnan(val2): * intersection += ps[col] # <<<<<<<<<<<<<< @@ -8019,7 +8356,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_39 = __pyx_v_col; __pyx_v_intersection = (__pyx_v_intersection + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_ps.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":404 + /* "Orange/distance/_distance.pyx":395 * if nonzeros1[row1, col] != 0: * union += 1 * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8029,7 +8366,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":397 * if npy_isnan(val2): * intersection += ps[col] * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8039,7 +8376,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":407 + /* "Orange/distance/_distance.pyx":398 * intersection += ps[col] * elif val2 != 0: * intersection += 1 # <<<<<<<<<<<<<< @@ -8048,7 +8385,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_intersection = (__pyx_v_intersection + 1.0); - /* "Orange/distance/_distance.pyx":406 + /* "Orange/distance/_distance.pyx":397 * if npy_isnan(val2): * intersection += ps[col] * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8058,7 +8395,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } __pyx_L23:; - /* "Orange/distance/_distance.pyx":402 + /* "Orange/distance/_distance.pyx":393 * for col in range(n_cols): * val2 = x2[row2, col] * if nonzeros1[row1, col] != 0: # <<<<<<<<<<<<<< @@ -8068,7 +8405,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L22; } - /* "Orange/distance/_distance.pyx":408 + /* "Orange/distance/_distance.pyx":399 * elif val2 != 0: * intersection += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8078,7 +8415,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":409 + /* "Orange/distance/_distance.pyx":400 * intersection += 1 * elif npy_isnan(val2): * union += ps[col] # <<<<<<<<<<<<<< @@ -8088,7 +8425,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_40 = __pyx_v_col; __pyx_v_union = (__pyx_v_union + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_ps.diminfo[0].strides))); - /* "Orange/distance/_distance.pyx":408 + /* "Orange/distance/_distance.pyx":399 * elif val2 != 0: * intersection += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8098,7 +8435,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L22; } - /* "Orange/distance/_distance.pyx":410 + /* "Orange/distance/_distance.pyx":401 * elif npy_isnan(val2): * union += ps[col] * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8108,7 +8445,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":411 + /* "Orange/distance/_distance.pyx":402 * union += ps[col] * elif val2 != 0: * union += 1 # <<<<<<<<<<<<<< @@ -8117,7 +8454,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + 1.0); - /* "Orange/distance/_distance.pyx":410 + /* "Orange/distance/_distance.pyx":401 * elif npy_isnan(val2): * union += ps[col] * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8128,7 +8465,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_L22:; } - /* "Orange/distance/_distance.pyx":399 + /* "Orange/distance/_distance.pyx":390 * union = intersection = 0 * # This case is slightly different since val1 can't be nan * if nans2[row2]: # <<<<<<<<<<<<<< @@ -8138,7 +8475,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU goto __pyx_L19; } - /* "Orange/distance/_distance.pyx":413 + /* "Orange/distance/_distance.pyx":404 * union += 1 * else: * for col in range(n_cols): # <<<<<<<<<<<<<< @@ -8150,7 +8487,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_col = __pyx_t_15; - /* "Orange/distance/_distance.pyx":414 + /* "Orange/distance/_distance.pyx":405 * else: * for col in range(n_cols): * ival1 = nonzeros1[row1, col] # <<<<<<<<<<<<<< @@ -8161,7 +8498,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_42 = __pyx_v_col; __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros1.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_nonzeros1.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_nonzeros1.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":415 + /* "Orange/distance/_distance.pyx":406 * for col in range(n_cols): * ival1 = nonzeros1[row1, col] * ival2 = nonzeros2[row2, col] # <<<<<<<<<<<<<< @@ -8172,7 +8509,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_44 = __pyx_v_col; __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros2.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_nonzeros2.diminfo[0].strides, __pyx_t_44, __pyx_pybuffernd_nonzeros2.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":416 + /* "Orange/distance/_distance.pyx":407 * ival1 = nonzeros1[row1, col] * ival2 = nonzeros2[row2, col] * union += ival1 | ival2 # <<<<<<<<<<<<<< @@ -8181,7 +8518,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ __pyx_v_union = (__pyx_v_union + (__pyx_v_ival1 | __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":417 + /* "Orange/distance/_distance.pyx":408 * ival2 = nonzeros2[row2, col] * union += ival1 | ival2 * intersection += ival1 & ival2 # <<<<<<<<<<<<<< @@ -8193,7 +8530,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } __pyx_L19:; - /* "Orange/distance/_distance.pyx":418 + /* "Orange/distance/_distance.pyx":409 * union += ival1 | ival2 * intersection += ival1 & ival2 * if union != 0: # <<<<<<<<<<<<<< @@ -8203,18 +8540,18 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":419 + /* "Orange/distance/_distance.pyx":410 * intersection += ival1 & ival2 * if union != 0: * distances[row1, row2] = 1 - intersection / union # <<<<<<<<<<<<<< * if not two_tables: - * _lower_to_symmetric(distances) + * lower_to_symmetric(distances) */ __pyx_t_45 = __pyx_v_row1; __pyx_t_46 = __pyx_v_row2; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_45 * __pyx_v_distances.strides[0]) ) + __pyx_t_46 * __pyx_v_distances.strides[1]) )) = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":418 + /* "Orange/distance/_distance.pyx":409 * union += ival1 | ival2 * intersection += ival1 & ival2 * if union != 0: # <<<<<<<<<<<<<< @@ -8228,7 +8565,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":366 + /* "Orange/distance/_distance.pyx":357 * n_rows2 = x2.shape[0] * distances = np.zeros((n_rows1, n_rows2), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8238,6 +8575,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -8246,49 +8584,49 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":420 + /* "Orange/distance/_distance.pyx":411 * if union != 0: * distances[row1, row2] = 1 - intersection / union * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) + * lower_to_symmetric(distances) * return distances */ __pyx_t_11 = ((!(__pyx_v_two_tables != 0)) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":421 + /* "Orange/distance/_distance.pyx":412 * distances[row1, row2] = 1 - intersection / union * if not two_tables: - * _lower_to_symmetric(distances) # <<<<<<<<<<<<<< + * lower_to_symmetric(distances) # <<<<<<<<<<<<<< * return distances * */ - __pyx_f_6Orange_8distance_9_distance__lower_to_symmetric(__pyx_v_distances); + __pyx_f_6Orange_8distance_9_distance_lower_to_symmetric(__pyx_v_distances, 0); - /* "Orange/distance/_distance.pyx":420 + /* "Orange/distance/_distance.pyx":411 * if union != 0: * distances[row1, row2] = 1 - intersection / union * if not two_tables: # <<<<<<<<<<<<<< - * _lower_to_symmetric(distances) + * lower_to_symmetric(distances) * return distances */ } - /* "Orange/distance/_distance.pyx":422 + /* "Orange/distance/_distance.pyx":413 * if not two_tables: - * _lower_to_symmetric(distances) + * lower_to_symmetric(distances) * return distances # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":340 * * * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< @@ -8333,7 +8671,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU return __pyx_r; } -/* "Orange/distance/_distance.pyx":425 +/* "Orange/distance/_distance.pyx":416 * * * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< @@ -8342,10 +8680,10 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_22jaccard_rows(CYTHON_UNU */ /* Python wrapper */ -static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6Orange_8distance_9_distance_24jaccard_cols[] = "jaccard_cols(ndarray nonzeros, ndarray x, ndarray nans, ndarray ps)"; -static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_25jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_24jaccard_cols}; -static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6Orange_8distance_9_distance_27jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6Orange_8distance_9_distance_26jaccard_cols[] = "jaccard_cols(ndarray nonzeros, ndarray x, ndarray nans, ndarray ps)"; +static PyMethodDef __pyx_mdef_6Orange_8distance_9_distance_27jaccard_cols = {"jaccard_cols", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_27jaccard_cols, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6Orange_8distance_9_distance_26jaccard_cols}; +static PyObject *__pyx_pw_6Orange_8distance_9_distance_27jaccard_cols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_nonzeros = 0; PyArrayObject *__pyx_v_x = 0; PyArrayObject *__pyx_v_nans = 0; @@ -8361,9 +8699,13 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject * const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { 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; } @@ -8372,24 +8714,27 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject * case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nonzeros)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 1); __PYX_ERR(0, 425, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 1); __PYX_ERR(0, 416, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nans)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 2); __PYX_ERR(0, 425, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 2); __PYX_ERR(0, 416, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ps)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 3); __PYX_ERR(0, 425, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, 3); __PYX_ERR(0, 416, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 425, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jaccard_cols") < 0)) __PYX_ERR(0, 416, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -8406,17 +8751,17 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 425, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("jaccard_cols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 416, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("Orange.distance._distance.jaccard_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros), __pyx_ptype_5numpy_ndarray, 1, "nonzeros", 0))) __PYX_ERR(0, 425, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 426, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans), __pyx_ptype_5numpy_ndarray, 1, "nans", 0))) __PYX_ERR(0, 427, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 428, __pyx_L1_error) - __pyx_r = __pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(__pyx_self, __pyx_v_nonzeros, __pyx_v_x, __pyx_v_nans, __pyx_v_ps); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonzeros), __pyx_ptype_5numpy_ndarray, 1, "nonzeros", 0))) __PYX_ERR(0, 416, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) __PYX_ERR(0, 417, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nans), __pyx_ptype_5numpy_ndarray, 1, "nans", 0))) __PYX_ERR(0, 418, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ps), __pyx_ptype_5numpy_ndarray, 1, "ps", 0))) __PYX_ERR(0, 419, __pyx_L1_error) + __pyx_r = __pyx_pf_6Orange_8distance_9_distance_26jaccard_cols(__pyx_self, __pyx_v_nonzeros, __pyx_v_x, __pyx_v_nans, __pyx_v_ps); /* function exit code */ goto __pyx_L0; @@ -8427,7 +8772,7 @@ static PyObject *__pyx_pw_6Orange_8distance_9_distance_25jaccard_cols(PyObject * return __pyx_r; } -static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps) { +static PyObject *__pyx_pf_6Orange_8distance_9_distance_26jaccard_cols(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_nonzeros, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_nans, PyArrayObject *__pyx_v_ps) { int __pyx_v_n_rows; int __pyx_v_n_cols; int __pyx_v_col1; @@ -8541,26 +8886,26 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_pybuffernd_ps.rcbuffer = &__pyx_pybuffer_ps; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nonzeros.rcbuffer->pybuffer, (PyObject*)__pyx_v_nonzeros, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 416, __pyx_L1_error) } __pyx_pybuffernd_nonzeros.diminfo[0].strides = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nonzeros.diminfo[0].shape = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nonzeros.diminfo[1].strides = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nonzeros.diminfo[1].shape = __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 416, __pyx_L1_error) } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nans.rcbuffer->pybuffer, (PyObject*)__pyx_v_nans, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 416, __pyx_L1_error) } __pyx_pybuffernd_nans.diminfo[0].strides = __pyx_pybuffernd_nans.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nans.diminfo[0].shape = __pyx_pybuffernd_nans.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 425, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ps.rcbuffer->pybuffer, (PyObject*)__pyx_v_ps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 416, __pyx_L1_error) } __pyx_pybuffernd_ps.diminfo[0].strides = __pyx_pybuffernd_ps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ps.diminfo[0].shape = __pyx_pybuffernd_ps.rcbuffer->pybuffer.shape[0]; - /* "Orange/distance/_distance.pyx":436 + /* "Orange/distance/_distance.pyx":427 * double [:, :] distances * * n_rows, n_cols = x.shape[0], x.shape[1] # <<<<<<<<<<<<<< @@ -8572,23 +8917,23 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_n_rows = __pyx_t_1; __pyx_v_n_cols = __pyx_t_2; - /* "Orange/distance/_distance.pyx":437 + /* "Orange/distance/_distance.pyx":428 * * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) # <<<<<<<<<<<<<< * with nogil: * for col1 in range(n_cols): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_cols); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -8596,27 +8941,27 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 437, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 428, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_3); - if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 437, __pyx_L1_error) + if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_distances = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":429 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -8627,10 +8972,11 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); #endif /*try:*/ { - /* "Orange/distance/_distance.pyx":439 + /* "Orange/distance/_distance.pyx":430 * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: * for col1 in range(n_cols): # <<<<<<<<<<<<<< @@ -8641,7 +8987,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_col1 = __pyx_t_9; - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":431 * with nogil: * for col1 in range(n_cols): * if nans[col1]: # <<<<<<<<<<<<<< @@ -8652,7 +8998,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_nans.diminfo[0].strides)) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":441 + /* "Orange/distance/_distance.pyx":432 * for col1 in range(n_cols): * if nans[col1]: * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -8663,7 +9009,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":442 + /* "Orange/distance/_distance.pyx":433 * if nans[col1]: * for col2 in range(col1): * in_both = in_any = 0 # <<<<<<<<<<<<<< @@ -8673,7 +9019,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_any = 0; - /* "Orange/distance/_distance.pyx":443 + /* "Orange/distance/_distance.pyx":434 * for col2 in range(col1): * in_both = in_any = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< @@ -8686,7 +9032,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_unk1_not2 = 0; __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":444 + /* "Orange/distance/_distance.pyx":435 * in_both = in_any = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -8697,7 +9043,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":445 + /* "Orange/distance/_distance.pyx":436 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] # <<<<<<<<<<<<<< @@ -8713,7 +9059,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_val1 = __pyx_t_18; __pyx_v_val2 = __pyx_t_21; - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":437 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8723,7 +9069,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val1) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":438 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8733,7 +9079,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":448 + /* "Orange/distance/_distance.pyx":439 * if npy_isnan(val1): * if npy_isnan(val2): * unk1_unk2 += 1 # <<<<<<<<<<<<<< @@ -8742,7 +9088,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_unk2 = (__pyx_v_unk1_unk2 + 1); - /* "Orange/distance/_distance.pyx":447 + /* "Orange/distance/_distance.pyx":438 * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8752,7 +9098,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":440 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8762,7 +9108,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val2 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":450 + /* "Orange/distance/_distance.pyx":441 * unk1_unk2 += 1 * elif val2 != 0: * unk1_in2 += 1 # <<<<<<<<<<<<<< @@ -8771,7 +9117,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_unk1_in2 = (__pyx_v_unk1_in2 + 1); - /* "Orange/distance/_distance.pyx":449 + /* "Orange/distance/_distance.pyx":440 * if npy_isnan(val2): * unk1_unk2 += 1 * elif val2 != 0: # <<<<<<<<<<<<<< @@ -8781,7 +9127,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L14; } - /* "Orange/distance/_distance.pyx":452 + /* "Orange/distance/_distance.pyx":443 * unk1_in2 += 1 * else: * unk1_not2 += 1 # <<<<<<<<<<<<<< @@ -8793,7 +9139,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } __pyx_L14:; - /* "Orange/distance/_distance.pyx":446 + /* "Orange/distance/_distance.pyx":437 * for row in range(n_rows): * val1, val2 = x[row, col1], x[row, col2] * if npy_isnan(val1): # <<<<<<<<<<<<<< @@ -8803,7 +9149,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":453 + /* "Orange/distance/_distance.pyx":444 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8813,7 +9159,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":454 + /* "Orange/distance/_distance.pyx":445 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8823,7 +9169,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((__pyx_v_val1 != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":455 + /* "Orange/distance/_distance.pyx":446 * elif npy_isnan(val2): * if val1 != 0: * in1_unk2 += 1 # <<<<<<<<<<<<<< @@ -8832,7 +9178,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "Orange/distance/_distance.pyx":454 + /* "Orange/distance/_distance.pyx":445 * unk1_not2 += 1 * elif npy_isnan(val2): * if val1 != 0: # <<<<<<<<<<<<<< @@ -8842,7 +9188,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L15; } - /* "Orange/distance/_distance.pyx":457 + /* "Orange/distance/_distance.pyx":448 * in1_unk2 += 1 * else: * not1_unk2 += 1 # <<<<<<<<<<<<<< @@ -8854,7 +9200,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } __pyx_L15:; - /* "Orange/distance/_distance.pyx":453 + /* "Orange/distance/_distance.pyx":444 * else: * unk1_not2 += 1 * elif npy_isnan(val2): # <<<<<<<<<<<<<< @@ -8864,7 +9210,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L13; } - /* "Orange/distance/_distance.pyx":459 + /* "Orange/distance/_distance.pyx":450 * not1_unk2 += 1 * else: * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< @@ -8876,7 +9222,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_23 = __pyx_v_col1; __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":460 + /* "Orange/distance/_distance.pyx":451 * else: * ival1 = nonzeros[row, col1] * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< @@ -8887,7 +9233,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_25 = __pyx_v_col2; __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":461 + /* "Orange/distance/_distance.pyx":452 * ival1 = nonzeros[row, col1] * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 # <<<<<<<<<<<<<< @@ -8896,7 +9242,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":462 + /* "Orange/distance/_distance.pyx":453 * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 * in_any += ival1 | ival2 # <<<<<<<<<<<<<< @@ -8908,7 +9254,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_L13:; } - /* "Orange/distance/_distance.pyx":464 + /* "Orange/distance/_distance.pyx":455 * in_any += ival1 | ival2 * union = (in_any + unk1_in2 + in1_unk2 * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< @@ -8917,7 +9263,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_26 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":465 + /* "Orange/distance/_distance.pyx":456 * union = (in_any + unk1_in2 + in1_unk2 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< @@ -8926,7 +9272,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_27 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":466 + /* "Orange/distance/_distance.pyx":457 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< @@ -8937,7 +9283,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_29 = __pyx_v_col2; __pyx_v_union = (((((__pyx_v_in_any + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_not2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_ps.diminfo[0].strides))) * (1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_ps.diminfo[0].strides))))) * __pyx_v_unk1_unk2)); - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":458 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * if union != 0: # <<<<<<<<<<<<<< @@ -8947,7 +9293,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((__pyx_v_union != 0.0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":469 + /* "Orange/distance/_distance.pyx":460 * if union != 0: * intersection = (in_both * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< @@ -8956,7 +9302,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_30 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":470 + /* "Orange/distance/_distance.pyx":461 * intersection = (in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -8965,7 +9311,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_31 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":471 + /* "Orange/distance/_distance.pyx":462 * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) # <<<<<<<<<<<<<< @@ -8975,7 +9321,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_32 = __pyx_v_col1; __pyx_t_33 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":470 + /* "Orange/distance/_distance.pyx":461 * intersection = (in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -8984,7 +9330,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_intersection = (((__pyx_v_in_both + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_in2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_in1_unk2)) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_ps.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_ps.diminfo[0].strides))) * __pyx_v_unk1_unk2)); - /* "Orange/distance/_distance.pyx":473 + /* "Orange/distance/_distance.pyx":464 * + ps[col1] * ps[col2] * unk1_unk2) * distances[col1, col2] = distances[col2, col1] = \ * 1 - intersection / union # <<<<<<<<<<<<<< @@ -8993,7 +9339,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_34 = (1.0 - (__pyx_v_intersection / __pyx_v_union)); - /* "Orange/distance/_distance.pyx":472 + /* "Orange/distance/_distance.pyx":463 * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -9007,7 +9353,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_38 = __pyx_v_col1; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_37 * __pyx_v_distances.strides[0]) ) + __pyx_t_38 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; - /* "Orange/distance/_distance.pyx":467 + /* "Orange/distance/_distance.pyx":458 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * if union != 0: # <<<<<<<<<<<<<< @@ -9017,7 +9363,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":440 + /* "Orange/distance/_distance.pyx":431 * with nogil: * for col1 in range(n_cols): * if nans[col1]: # <<<<<<<<<<<<<< @@ -9027,7 +9373,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L8; } - /* "Orange/distance/_distance.pyx":475 + /* "Orange/distance/_distance.pyx":466 * 1 - intersection / union * else: * for col2 in range(col1): # <<<<<<<<<<<<<< @@ -9039,7 +9385,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_col2 = __pyx_t_13; - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":467 * else: * for col2 in range(col1): * if nans[col2]: # <<<<<<<<<<<<<< @@ -9050,7 +9396,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nans.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_nans.diminfo[0].strides)) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":477 + /* "Orange/distance/_distance.pyx":468 * for col2 in range(col1): * if nans[col2]: * in_both = in_any = 0 # <<<<<<<<<<<<<< @@ -9060,7 +9406,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_any = 0; - /* "Orange/distance/_distance.pyx":478 + /* "Orange/distance/_distance.pyx":469 * if nans[col2]: * in_both = in_any = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 # <<<<<<<<<<<<<< @@ -9073,7 +9419,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_unk1_not2 = 0; __pyx_v_not1_unk2 = 0; - /* "Orange/distance/_distance.pyx":479 + /* "Orange/distance/_distance.pyx":470 * in_both = in_any = 0 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -9084,7 +9430,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":480 + /* "Orange/distance/_distance.pyx":471 * in1_unk2 = unk1_in2 = unk1_unk2 = unk1_not2 = not1_unk2 = 0 * for row in range(n_rows): * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< @@ -9095,7 +9441,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_41 = __pyx_v_col1; __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":481 + /* "Orange/distance/_distance.pyx":472 * for row in range(n_rows): * ival1 = nonzeros[row, col1] * val2 = x[row, col2] # <<<<<<<<<<<<<< @@ -9106,7 +9452,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_43 = __pyx_v_col2; __pyx_v_val2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_x.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_x.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":482 + /* "Orange/distance/_distance.pyx":473 * ival1 = nonzeros[row, col1] * val2 = x[row, col2] * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9116,7 +9462,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = (npy_isnan(__pyx_v_val2) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":483 + /* "Orange/distance/_distance.pyx":474 * val2 = x[row, col2] * if npy_isnan(val2): * if ival1: # <<<<<<<<<<<<<< @@ -9126,7 +9472,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = (__pyx_v_ival1 != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":484 + /* "Orange/distance/_distance.pyx":475 * if npy_isnan(val2): * if ival1: * in1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9135,7 +9481,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_in1_unk2 = (__pyx_v_in1_unk2 + 1); - /* "Orange/distance/_distance.pyx":483 + /* "Orange/distance/_distance.pyx":474 * val2 = x[row, col2] * if npy_isnan(val2): * if ival1: # <<<<<<<<<<<<<< @@ -9145,7 +9491,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L23; } - /* "Orange/distance/_distance.pyx":486 + /* "Orange/distance/_distance.pyx":477 * in1_unk2 += 1 * else: * not1_unk2 += 1 # <<<<<<<<<<<<<< @@ -9157,7 +9503,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } __pyx_L23:; - /* "Orange/distance/_distance.pyx":482 + /* "Orange/distance/_distance.pyx":473 * ival1 = nonzeros[row, col1] * val2 = x[row, col2] * if npy_isnan(val2): # <<<<<<<<<<<<<< @@ -9167,7 +9513,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L22; } - /* "Orange/distance/_distance.pyx":488 + /* "Orange/distance/_distance.pyx":479 * not1_unk2 += 1 * else: * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< @@ -9179,7 +9525,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_45 = __pyx_v_col2; __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":489 + /* "Orange/distance/_distance.pyx":480 * else: * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 # <<<<<<<<<<<<<< @@ -9188,7 +9534,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":490 + /* "Orange/distance/_distance.pyx":481 * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 * in_any += ival1 | ival2 # <<<<<<<<<<<<<< @@ -9200,7 +9546,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_L22:; } - /* "Orange/distance/_distance.pyx":493 + /* "Orange/distance/_distance.pyx":484 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both * + ps[col1] * unk1_in2 + # <<<<<<<<<<<<<< @@ -9209,7 +9555,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_46 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":494 + /* "Orange/distance/_distance.pyx":485 * 1 - float(in_both * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + # <<<<<<<<<<<<<< @@ -9218,7 +9564,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_47 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":495 + /* "Orange/distance/_distance.pyx":486 * + ps[col1] * unk1_in2 + * + ps[col2] * in1_unk2 + * + ps[col1] * ps[col2] * unk1_unk2) / \ # <<<<<<<<<<<<<< @@ -9228,7 +9574,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_48 = __pyx_v_col1; __pyx_t_49 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":497 + /* "Orange/distance/_distance.pyx":488 * + ps[col1] * ps[col2] * unk1_unk2) / \ * (in_any + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 # <<<<<<<<<<<<<< @@ -9237,7 +9583,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_50 = __pyx_v_col1; - /* "Orange/distance/_distance.pyx":498 + /* "Orange/distance/_distance.pyx":489 * (in_any + unk1_in2 + in1_unk2 + * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 # <<<<<<<<<<<<<< @@ -9246,7 +9592,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_51 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":499 + /* "Orange/distance/_distance.pyx":490 * + ps[col1] * unk1_not2 * + ps[col2] * not1_unk2 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) # <<<<<<<<<<<<<< @@ -9256,7 +9602,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_52 = __pyx_v_col1; __pyx_t_53 = __pyx_v_col2; - /* "Orange/distance/_distance.pyx":492 + /* "Orange/distance/_distance.pyx":483 * in_any += ival1 | ival2 * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both # <<<<<<<<<<<<<< @@ -9265,7 +9611,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_21 = (1.0 - (((double)(((__pyx_v_in_both + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_in2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_in1_unk2)) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_ps.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_49, __pyx_pybuffernd_ps.diminfo[0].strides))) * __pyx_v_unk1_unk2))) / (((((__pyx_v_in_any + __pyx_v_unk1_in2) + __pyx_v_in1_unk2) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_50, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_unk1_not2)) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_51, __pyx_pybuffernd_ps.diminfo[0].strides)) * __pyx_v_not1_unk2)) + ((1.0 - ((1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_ps.diminfo[0].strides))) * (1.0 - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_ps.rcbuffer->pybuffer.buf, __pyx_t_53, __pyx_pybuffernd_ps.diminfo[0].strides))))) * __pyx_v_unk1_unk2)))); - /* "Orange/distance/_distance.pyx":491 + /* "Orange/distance/_distance.pyx":482 * in_both += ival1 & ival2 * in_any += ival1 | ival2 * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -9279,7 +9625,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_57 = __pyx_v_col1; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_56 * __pyx_v_distances.strides[0]) ) + __pyx_t_57 * __pyx_v_distances.strides[1]) )) = __pyx_t_21; - /* "Orange/distance/_distance.pyx":476 + /* "Orange/distance/_distance.pyx":467 * else: * for col2 in range(col1): * if nans[col2]: # <<<<<<<<<<<<<< @@ -9289,7 +9635,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU goto __pyx_L19; } - /* "Orange/distance/_distance.pyx":501 + /* "Orange/distance/_distance.pyx":492 * + (1 - (1 - ps[col1]) * (1 - ps[col2])) * unk1_unk2) * else: * in_both = in_any = 0 # <<<<<<<<<<<<<< @@ -9300,7 +9646,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_in_both = 0; __pyx_v_in_any = 0; - /* "Orange/distance/_distance.pyx":502 + /* "Orange/distance/_distance.pyx":493 * else: * in_both = in_any = 0 * for row in range(n_rows): # <<<<<<<<<<<<<< @@ -9311,7 +9657,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_row = __pyx_t_15; - /* "Orange/distance/_distance.pyx":503 + /* "Orange/distance/_distance.pyx":494 * in_both = in_any = 0 * for row in range(n_rows): * ival1 = nonzeros[row, col1] # <<<<<<<<<<<<<< @@ -9322,7 +9668,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_59 = __pyx_v_col1; __pyx_v_ival1 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_59, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":504 + /* "Orange/distance/_distance.pyx":495 * for row in range(n_rows): * ival1 = nonzeros[row, col1] * ival2 = nonzeros[row, col2] # <<<<<<<<<<<<<< @@ -9333,7 +9679,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_61 = __pyx_v_col2; __pyx_v_ival2 = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_nonzeros.rcbuffer->pybuffer.buf, __pyx_t_60, __pyx_pybuffernd_nonzeros.diminfo[0].strides, __pyx_t_61, __pyx_pybuffernd_nonzeros.diminfo[1].strides)); - /* "Orange/distance/_distance.pyx":505 + /* "Orange/distance/_distance.pyx":496 * ival1 = nonzeros[row, col1] * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 # <<<<<<<<<<<<<< @@ -9342,7 +9688,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_v_in_both = (__pyx_v_in_both + (__pyx_v_ival1 & __pyx_v_ival2)); - /* "Orange/distance/_distance.pyx":506 + /* "Orange/distance/_distance.pyx":497 * ival2 = nonzeros[row, col2] * in_both += ival1 & ival2 * in_any += ival1 | ival2 # <<<<<<<<<<<<<< @@ -9352,7 +9698,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_v_in_any = (__pyx_v_in_any + (__pyx_v_ival1 | __pyx_v_ival2)); } - /* "Orange/distance/_distance.pyx":507 + /* "Orange/distance/_distance.pyx":498 * in_both += ival1 & ival2 * in_any += ival1 | ival2 * if in_any != 0: # <<<<<<<<<<<<<< @@ -9362,7 +9708,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_11 = ((__pyx_v_in_any != 0) != 0); if (__pyx_t_11) { - /* "Orange/distance/_distance.pyx":509 + /* "Orange/distance/_distance.pyx":500 * if in_any != 0: * distances[col1, col2] = distances[col2, col1] = \ * 1 - float(in_both) / in_any # <<<<<<<<<<<<<< @@ -9371,7 +9717,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU */ __pyx_t_34 = (1.0 - (((double)__pyx_v_in_both) / __pyx_v_in_any)); - /* "Orange/distance/_distance.pyx":508 + /* "Orange/distance/_distance.pyx":499 * in_any += ival1 | ival2 * if in_any != 0: * distances[col1, col2] = distances[col2, col1] = \ # <<<<<<<<<<<<<< @@ -9385,7 +9731,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU __pyx_t_65 = __pyx_v_col1; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_64 * __pyx_v_distances.strides[0]) ) + __pyx_t_65 * __pyx_v_distances.strides[1]) )) = __pyx_t_34; - /* "Orange/distance/_distance.pyx":507 + /* "Orange/distance/_distance.pyx":498 * in_both += ival1 & ival2 * in_any += ival1 | ival2 * if in_any != 0: # <<<<<<<<<<<<<< @@ -9401,7 +9747,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":438 + /* "Orange/distance/_distance.pyx":429 * n_rows, n_cols = x.shape[0], x.shape[1] * distances = np.zeros((n_cols, n_cols), dtype=float) * with nogil: # <<<<<<<<<<<<<< @@ -9411,6 +9757,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; @@ -9419,19 +9766,19 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU } } - /* "Orange/distance/_distance.pyx":511 + /* "Orange/distance/_distance.pyx":502 * 1 - float(in_both) / in_any * * return distances # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error) + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_distances, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "Orange/distance/_distance.pyx":425 + /* "Orange/distance/_distance.pyx":416 * * * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< @@ -9470,7 +9817,7 @@ static PyObject *__pyx_pf_6Orange_8distance_9_distance_24jaccard_cols(CYTHON_UNU return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -9517,7 +9864,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_GIVEREF(__pyx_v_info->obj); } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< @@ -9530,7 +9877,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L0; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -9539,7 +9886,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -9548,7 +9895,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -9557,7 +9904,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -9567,7 +9914,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -9576,7 +9923,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_copy_shape = 1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -9586,7 +9933,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L4; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -9598,7 +9945,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L4:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9612,7 +9959,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L6_bool_binop_done; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -9623,7 +9970,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9632,7 +9979,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -9645,7 +9992,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 218, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9654,7 +10001,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9668,7 +10015,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L9_bool_binop_done; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -9679,7 +10026,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9688,7 +10035,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -9701,7 +10048,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 222, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -9710,7 +10057,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -9719,7 +10066,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -9728,7 +10075,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -9738,7 +10085,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -9747,7 +10094,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -9756,7 +10103,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -9767,7 +10114,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -9776,7 +10123,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -9786,7 +10133,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -9796,7 +10143,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L11; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -9806,7 +10153,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -9817,7 +10164,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L11:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -9826,7 +10173,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -9835,7 +10182,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -9844,7 +10191,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -9853,7 +10200,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< @@ -9865,7 +10212,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -9874,7 +10221,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -9892,7 +10239,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_L15_bool_binop_done:; if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -9905,7 +10252,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -9915,7 +10262,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L14; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< @@ -9931,7 +10278,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L14:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -9941,7 +10288,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -9951,7 +10298,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -9971,7 +10318,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L20_next_or:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -9988,7 +10335,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -9997,7 +10344,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -10010,7 +10357,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 259, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -10019,7 +10366,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -10031,7 +10378,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"b"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -10042,7 +10389,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"B"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -10053,7 +10400,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"h"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -10064,7 +10411,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"H"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -10075,7 +10422,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"i"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -10086,7 +10433,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"I"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -10097,7 +10444,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"l"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -10108,7 +10455,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"L"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -10119,7 +10466,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"q"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -10130,7 +10477,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"Q"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -10141,7 +10488,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"f"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -10152,7 +10499,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"d"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -10163,7 +10510,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"g"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -10174,7 +10521,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"Zf"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -10185,7 +10532,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"Zd"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -10196,7 +10543,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = ((char *)"Zg"); break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -10208,7 +10555,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; default: - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -10234,7 +10581,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -10243,7 +10590,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -10253,7 +10600,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_r = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -10262,7 +10609,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -10272,7 +10619,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -10281,7 +10628,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -10290,7 +10637,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< @@ -10300,7 +10647,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) __pyx_v_f = __pyx_t_7; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -10310,7 +10657,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -10342,7 +10689,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -10366,7 +10713,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -10376,7 +10723,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -10385,7 +10732,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ free(__pyx_v_info->format); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -10394,7 +10741,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -10404,7 +10751,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -10413,7 +10760,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ free(__pyx_v_info->strides); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -10422,7 +10769,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -10434,7 +10781,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __Pyx_RefNannyFinishContext(); } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -10448,7 +10795,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -10462,7 +10809,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -10481,7 +10828,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -10495,7 +10842,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -10509,7 +10856,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -10528,7 +10875,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -10542,7 +10889,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -10556,7 +10903,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -10575,7 +10922,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -10589,7 +10936,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -10603,7 +10950,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -10622,7 +10969,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -10636,7 +10983,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -10650,7 +10997,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -10669,7 +11016,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -10698,7 +11045,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -10707,7 +11054,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -10716,7 +11063,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -10730,7 +11077,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) @@ -10739,7 +11086,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -10756,7 +11103,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -10765,7 +11112,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -10775,7 +11122,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 796, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); @@ -10795,7 +11142,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -10812,7 +11159,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -10825,7 +11172,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 799, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -10834,7 +11181,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -10854,7 +11201,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -10871,7 +11218,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -10880,7 +11227,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -10893,7 +11240,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 803, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -10902,7 +11249,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -10918,7 +11265,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -10927,7 +11274,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 0x78; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -10936,7 +11283,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -10947,7 +11294,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -10957,7 +11304,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -10967,7 +11314,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -10979,7 +11326,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -10989,7 +11336,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -11002,7 +11349,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 823, __pyx_L1_error) - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -11011,7 +11358,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -11029,7 +11376,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< @@ -11047,7 +11394,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -11065,7 +11412,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -11083,7 +11430,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -11101,7 +11448,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -11119,7 +11466,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -11137,7 +11484,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -11155,7 +11502,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -11173,7 +11520,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -11191,7 +11538,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -11209,7 +11556,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -11227,7 +11574,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -11245,7 +11592,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< @@ -11265,7 +11612,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< @@ -11285,7 +11632,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< @@ -11305,7 +11652,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< @@ -11323,7 +11670,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -11347,7 +11694,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L15:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -11356,7 +11703,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -11366,7 +11713,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -11379,7 +11726,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L13:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -11389,7 +11736,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -11399,7 +11746,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -11424,7 +11771,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -11439,7 +11786,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -11450,7 +11797,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< @@ -11459,7 +11806,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ __pyx_v_baseptr = NULL; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -11469,7 +11816,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a goto __pyx_L3; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< @@ -11479,7 +11826,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a /*else*/ { Py_INCREF(__pyx_v_base); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< @@ -11490,7 +11837,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } __pyx_L3:; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< @@ -11499,7 +11846,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_XDECREF(__pyx_v_arr->base); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< @@ -11508,7 +11855,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ __pyx_v_arr->base = __pyx_v_baseptr; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -11520,7 +11867,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -11534,7 +11881,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -11544,7 +11891,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< @@ -11556,7 +11903,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; goto __pyx_L0; - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -11565,10 +11912,12 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< + * + * */ /*else*/ { __Pyx_XDECREF(__pyx_r); @@ -11577,7 +11926,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py goto __pyx_L0; } - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -11592,26 +11941,416 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "View.MemoryView":120 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":985 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() */ -/* Python wrapper */ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_shape = 0; - Py_ssize_t __pyx_v_itemsize; - PyObject *__pyx_v_format = 0; - PyObject *__pyx_v_mode = 0; - int __pyx_v_allocate_buffer; +static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_array", 0); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":986 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":987 + * cdef inline int import_array() except -1: + * try: + * _import_array() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") + */ + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 987, __pyx_L3_error) + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":986 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":988 + * try: + * _import_array() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.multiarray failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 988, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":989 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 989, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 989, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":986 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":985 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":991 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_umath", 0); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":992 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":993 + * cdef inline int import_umath() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 993, __pyx_L3_error) + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":992 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":994 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 994, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":995 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 995, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 995, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":992 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":991 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_ufunc", 0); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":998 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":999 + * cdef inline int import_ufunc() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 999, __pyx_L3_error) + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":998 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1000, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1001, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1001, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":998 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":120 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + +/* Python wrapper */ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_shape = 0; + Py_ssize_t __pyx_v_itemsize; + PyObject *__pyx_v_format = 0; + PyObject *__pyx_v_mode = 0; + int __pyx_v_allocate_buffer; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)__pyx_n_s_c); @@ -11620,10 +12359,15 @@ static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, P 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; } @@ -11632,21 +12376,25 @@ static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, P case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 120, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 120, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode); if (value) { values[3] = value; kw_args--; } } + CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer); @@ -11659,7 +12407,9 @@ static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, P } else { switch (PyTuple_GET_SIZE(__pyx_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); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -11777,7 +12527,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if itemsize <= 0: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11809,7 +12559,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if not isinstance(format, bytes): */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11844,7 +12594,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5); @@ -11882,7 +12632,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * */ - __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(2, 139, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(2, 139, __pyx_L1_error) __pyx_v_self->format = __pyx_t_6; /* "View.MemoryView":142 @@ -11920,7 +12670,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -11946,7 +12696,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; for (;;) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(2, 149, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 149, __pyx_L1_error) @@ -12204,7 +12954,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if self.dtype_is_object: */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -12442,7 +13192,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(stru * info.buf = self.data * info.len = self.len */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -13077,41 +13827,148 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struc return __pyx_r; } -/* "View.MemoryView":240 - * - * @cname("__pyx_array_new") - * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< - * char *mode, char *buf): - * cdef array result +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): */ -static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { - struct __pyx_array_obj *__pyx_v_result = 0; - struct __pyx_array_obj *__pyx_r = NULL; +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("array_cwrapper", 0); + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self)); - /* "View.MemoryView":244 - * cdef array result - * - * if buf == NULL: # <<<<<<<<<<<<<< - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - */ - __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); - if (__pyx_t_1) { + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "View.MemoryView":245 - * - * if buf == NULL: - * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), +static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":240 + * + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result + */ + +static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { + struct __pyx_array_obj *__pyx_v_result = 0; + struct __pyx_array_obj *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("array_cwrapper", 0); + + /* "View.MemoryView":244 + * cdef array result + * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + */ + __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":245 + * + * if buf == NULL: + * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), */ __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -13272,6 +14129,7 @@ static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_ar const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } @@ -13391,6 +14249,293 @@ static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr_ return __pyx_r; } +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * cdef bint use_setstate + * state = (self.name,) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { + int __pyx_v_use_setstate; + PyObject *__pyx_v_state = NULL; + PyObject *__pyx_v__dict = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * cdef bint use_setstate + * state = (self.name,) # <<<<<<<<<<<<<< + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_self->name); + __Pyx_GIVEREF(__pyx_v_self->name); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name); + __pyx_v_state = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "(tree fragment)":4 + * cdef bint use_setstate + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< + * if _dict is not None: + * state += _dict, + */ + __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v__dict = __pyx_t_1; + __pyx_t_1 = 0; + + /* "(tree fragment)":5 + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: # <<<<<<<<<<<<<< + * state += _dict, + * use_setstate = True + */ + __pyx_t_2 = (__pyx_v__dict != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":6 + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: + * state += _dict, # <<<<<<<<<<<<<< + * use_setstate = True + * else: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v__dict); + __Pyx_GIVEREF(__pyx_v__dict); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict); + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + /* "(tree fragment)":7 + * if _dict is not None: + * state += _dict, + * use_setstate = True # <<<<<<<<<<<<<< + * else: + * use_setstate = self.name is not None + */ + __pyx_v_use_setstate = 1; + + /* "(tree fragment)":5 + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: # <<<<<<<<<<<<<< + * state += _dict, + * use_setstate = True + */ + goto __pyx_L3; + } + + /* "(tree fragment)":9 + * use_setstate = True + * else: + * use_setstate = self.name is not None # <<<<<<<<<<<<<< + * if use_setstate: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + */ + /*else*/ { + __pyx_t_3 = (__pyx_v_self->name != Py_None); + __pyx_v_use_setstate = __pyx_t_3; + } + __pyx_L3:; + + /* "(tree fragment)":10 + * else: + * use_setstate = self.name is not None + * if use_setstate: # <<<<<<<<<<<<<< + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + */ + __pyx_t_3 = (__pyx_v_use_setstate != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":11 + * use_setstate = self.name is not None + * if use_setstate: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<< + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_INCREF(__pyx_int_184977713); + __Pyx_GIVEREF(__pyx_int_184977713); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None); + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __Pyx_INCREF(__pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state); + __pyx_t_4 = 0; + __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "(tree fragment)":10 + * else: + * use_setstate = self.name is not None + * if use_setstate: # <<<<<<<<<<<<<< + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + */ + } + + /* "(tree fragment)":13 + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_INCREF(__pyx_int_184977713); + __Pyx_GIVEREF(__pyx_int_184977713); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); + __Pyx_INCREF(__pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + } + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * cdef bint use_setstate + * state = (self.name,) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_state); + __Pyx_XDECREF(__pyx_v__dict); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":14 + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":15 + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): + * __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<< + */ + if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error) + __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "(tree fragment)":14 + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "View.MemoryView":294 * * @cname('__pyx_align_pointer') @@ -13499,8 +14644,11 @@ static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_ar const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } @@ -13509,11 +14657,13 @@ static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_ar case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 341, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object); @@ -13526,6 +14676,7 @@ static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_ar } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; @@ -14083,7 +15234,7 @@ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__py if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) @@ -14091,7 +15242,7 @@ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__py #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(2, 389, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 389, __pyx_L1_error) @@ -14244,7 +15395,7 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4_ __Pyx_GOTREF(__pyx_t_3); if (likely(__pyx_t_3 != Py_None)) { PyObject* sequence = __pyx_t_3; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -14254,7 +15405,7 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4_ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(2, 399, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_4); @@ -14400,7 +15551,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit __Pyx_GOTREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -14410,7 +15561,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(2, 409, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); @@ -14658,7 +15809,7 @@ static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_ __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L11_try_end; + goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -14718,7 +15869,7 @@ static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; - __pyx_L11_try_end:; + __pyx_L9_try_end:; } /* "View.MemoryView":421 @@ -15212,11 +16363,10 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; + int __pyx_t_8; PyObject *__pyx_t_9 = NULL; size_t __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; __Pyx_RefNannySetupContext("convert_item_to_object", 0); /* "View.MemoryView":477 @@ -15272,7 +16422,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); @@ -15282,20 +16432,40 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview __pyx_t_8 = 1; } } - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); + __Pyx_INCREF(__pyx_v_bytesitem); + __Pyx_GIVEREF(__pyx_v_bytesitem); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); - __Pyx_INCREF(__pyx_v_bytesitem); - __Pyx_GIVEREF(__pyx_v_bytesitem); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_result = __pyx_t_1; __pyx_t_1 = 0; @@ -15373,9 +16543,9 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 483, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); + __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_12) { + if (__pyx_t_8) { __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(2, 483, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); @@ -15389,7 +16559,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview * else: * if len(self.view.format) == 1: */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 484, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -15467,13 +16637,14 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - Py_ssize_t __pyx_t_7; + int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - char *__pyx_t_10; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; char *__pyx_t_11; char *__pyx_t_12; char *__pyx_t_13; + char *__pyx_t_14; __Pyx_RefNannySetupContext("assign_item_from_object", 0); /* "View.MemoryView":493 @@ -15553,7 +16724,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_7 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); @@ -15563,20 +16734,40 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __pyx_t_7 = 1; } } - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 501, __pyx_L1_error) __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); @@ -15591,18 +16782,18 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * itemp[i] = c * */ - __pyx_t_7 = 0; + __pyx_t_9 = 0; if (unlikely(__pyx_v_bytesvalue == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); __PYX_ERR(2, 503, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_bytesvalue); - __pyx_t_9 = __pyx_v_bytesvalue; - __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9); - __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9)); - for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) { - __pyx_t_10 = __pyx_t_13; - __pyx_v_c = (__pyx_t_10[0]); + __pyx_t_10 = __pyx_v_bytesvalue; + __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10); + __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10)); + for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) { + __pyx_t_11 = __pyx_t_14; + __pyx_v_c = (__pyx_t_11[0]); /* "View.MemoryView":504 * @@ -15611,7 +16802,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * * @cname('getbuffer') */ - __pyx_v_i = __pyx_t_7; + __pyx_v_i = __pyx_t_9; /* "View.MemoryView":503 * bytesvalue = struct.pack(self.view.format, value) @@ -15620,7 +16811,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * itemp[i] = c * */ - __pyx_t_7 = (__pyx_t_7 + 1); + __pyx_t_9 = (__pyx_t_9 + 1); /* "View.MemoryView":504 * @@ -15631,7 +16822,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie */ (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "View.MemoryView":490 * return result @@ -15650,7 +16841,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -16209,7 +17400,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -16323,7 +17514,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__15, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__20, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; @@ -17299,6 +18490,113 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22 return __pyx_r; } +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "View.MemoryView":643 * * @cname('__pyx_memoryview_new') @@ -17557,7 +18855,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) @@ -17565,7 +18863,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 665, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 665, __pyx_L1_error) @@ -17627,9 +18925,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_7); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__16); - __Pyx_GIVEREF(__pyx_slice__16); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__16); + __Pyx_INCREF(__pyx_slice__23); + __Pyx_GIVEREF(__pyx_slice__23); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__23); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 668, __pyx_L1_error) @@ -17662,7 +18960,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * else: */ /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__17); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__24); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 671, __pyx_L1_error) } __pyx_L7:; @@ -17807,9 +19105,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__18); - __Pyx_GIVEREF(__pyx_slice__18); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__18); + __Pyx_INCREF(__pyx_slice__25); + __Pyx_GIVEREF(__pyx_slice__25); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__25); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(2, 682, __pyx_L1_error) @@ -17933,7 +19231,7 @@ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __ * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -18168,7 +19466,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) @@ -18176,7 +19474,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(2, 732, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 732, __pyx_L1_error) @@ -19316,11 +20614,11 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_L1_error:; { #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_r = -1; @@ -19801,11 +21099,11 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { __pyx_L1_error:; { #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_r = 0; @@ -20073,6 +21371,113 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__ return __pyx_r; } +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(2, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "View.MemoryView":985 * * @cname('__pyx_memoryview_fromslice') @@ -20517,7 +21922,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); @@ -21774,11 +23179,11 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_L1_error:; { #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_r = NULL; @@ -21802,7 +23207,7 @@ static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("_err_extents", 0); @@ -21871,7 +23276,7 @@ static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent __pyx_r = -1; __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } @@ -21893,7 +23298,7 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("_err_dim", 0); __Pyx_INCREF(__pyx_v_error); @@ -21915,7 +23320,7 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_error); __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); @@ -21929,15 +23334,35 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1242, __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 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 1242, __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 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); @@ -21964,7 +23389,7 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_XDECREF(__pyx_v_error); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } @@ -21987,7 +23412,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("_err", 0); __Pyx_INCREF(__pyx_v_error); @@ -22013,7 +23438,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_error); __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); @@ -22027,15 +23452,35 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); @@ -22083,7 +23528,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_XDECREF(__pyx_v_error); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } @@ -22650,11 +24095,11 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_L1_error:; { #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_r = -1; @@ -22834,7 +24279,7 @@ static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, i static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { __Pyx_RefNannyDeclarations #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); @@ -22858,7 +24303,7 @@ static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_da /* function exit code */ __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); + __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } @@ -23167,44 +24612,508 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t /* function exit code */ } -static struct __pyx_vtabstruct_array __pyx_vtable_array; -static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_array_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_array_obj *)o); - p->__pyx_vtab = __pyx_vtabptr_array; - p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); - p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } - return o; -} +/* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError + */ -static void __pyx_tp_dealloc_array(PyObject *o) { - struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v___pyx_type = 0; + long __pyx_v___pyx_checksum; + PyObject *__pyx_v___pyx_state = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0); { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_array___dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; + PyObject* values[3] = {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 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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(2, 1, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + 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); + } + __pyx_v___pyx_type = values[0]; + __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error) + __pyx_v___pyx_state = values[2]; } - Py_CLEAR(p->mode); - Py_CLEAR(p->_format); + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_v_PickleError = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0); + + /* "(tree fragment)":2 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): + * if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<< + * from pickle import PickleError + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + */ + __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0); + if (__pyx_t_1) { + + /* "(tree fragment)":3 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError # <<<<<<<<<<<<<< + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + * result = Enum.__new__(__pyx_type) + */ + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_PickleError); + __Pyx_GIVEREF(__pyx_n_s_PickleError); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError); + __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_2); + __pyx_v_PickleError = __pyx_t_2; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "(tree fragment)":4 + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) # <<<<<<<<<<<<<< + * result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: + */ + __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_INCREF(__pyx_v_PickleError); + __pyx_t_2 = __pyx_v_PickleError; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 4, __pyx_L1_error) + + /* "(tree fragment)":2 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): + * if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<< + * from pickle import PickleError + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + */ + } + + /* "(tree fragment)":5 + * from pickle import PickleError + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + * result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<< + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_6) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_INCREF(__pyx_v___pyx_type); + __Pyx_GIVEREF(__pyx_v___pyx_type); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_result = __pyx_t_3; + __pyx_t_3 = 0; + + /* "(tree fragment)":6 + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + * result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result + */ + __pyx_t_1 = (__pyx_v___pyx_state != Py_None); + __pyx_t_7 = (__pyx_t_1 != 0); + if (__pyx_t_7) { + + /* "(tree fragment)":7 + * result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( result, __pyx_state) # <<<<<<<<<<<<<< + * return result + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): + */ + if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error) + __pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "(tree fragment)":6 + * raise PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) + * result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result + */ + } + + /* "(tree fragment)":8 + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result # <<<<<<<<<<<<<< + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): + * result.name = __pyx_state[0] + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_PickleError); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":9 + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): # <<<<<<<<<<<<<< + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): + */ + +static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v_result, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0); + + /* "(tree fragment)":10 + * return result + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): + * result.name = __pyx_state[0] # <<<<<<<<<<<<<< + * if hasattr(result, '__dict__'): + * result.__dict__.update(__pyx_state[1]) + */ + if (unlikely(__pyx_v___pyx_state == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(2, 10, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_result->name); + __Pyx_DECREF(__pyx_v_result->name); + __pyx_v_result->name = __pyx_t_1; + __pyx_t_1 = 0; + + /* "(tree fragment)":11 + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): # <<<<<<<<<<<<<< + * result.__dict__.update(__pyx_state[1]) + */ + __pyx_t_2 = __Pyx_HasAttr(((PyObject *)__pyx_v_result), __pyx_n_s_dict); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(2, 11, __pyx_L1_error) + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":12 + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): + * result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<< + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_update); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(__pyx_v___pyx_state == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(2, 12, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_6) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "(tree fragment)":11 + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): # <<<<<<<<<<<<<< + * result.__dict__.update(__pyx_state[1]) + */ + } + + /* "(tree fragment)":9 + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): # <<<<<<<<<<<<<< + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_array __pyx_vtable_array; + +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_array_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_array_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_array; + p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_array(PyObject *o) { + struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_array___dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->mode); + Py_CLEAR(p->_format); (*Py_TYPE(o)->tp_free)(o); } static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { @@ -23241,6 +25150,8 @@ static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED vo static PyMethodDef __pyx_methods_array[] = { {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; @@ -23360,7 +25271,7 @@ static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, C static void __pyx_tp_dealloc_Enum(PyObject *o) { struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif @@ -23388,6 +25299,8 @@ static int __pyx_tp_clear_Enum(PyObject *o) { } static PyMethodDef __pyx_methods_Enum[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; @@ -23465,16 +25378,17 @@ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject p->_size = Py_None; Py_INCREF(Py_None); p->_array_interface = Py_None; Py_INCREF(Py_None); p->view.obj = NULL; - if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } + if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad; return o; + bad: + Py_DECREF(o); o = 0; + return NULL; } static void __pyx_tp_dealloc_memoryview(PyObject *o) { struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif @@ -23586,6 +25500,8 @@ static PyMethodDef __pyx_methods_memoryview[] = { {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; @@ -23711,7 +25627,7 @@ static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyO static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif @@ -23755,6 +25671,8 @@ static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UN } static PyMethodDef __pyx_methods__memoryviewslice[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; @@ -23830,6 +25748,7 @@ static PyTypeObject __pyx_type___pyx_memoryviewslice = { }; static PyMethodDef __pyx_methods[] = { + {"lower_to_symmetric", (PyCFunction)__pyx_pw_6Orange_8distance_9_distance_1lower_to_symmetric, METH_O, __pyx_doc_6Orange_8distance_9_distance_lower_to_symmetric}, {0, 0, 0, 0} }; @@ -23860,6 +25779,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0}, {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, @@ -23870,24 +25791,28 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, {&__pyx_n_s_Orange_distance__distance, __pyx_k_Orange_distance__distance, sizeof(__pyx_k_Orange_distance__distance), 0, 0, 1, 1}, + {&__pyx_kp_s_Orange_distance__distance_pyx, __pyx_k_Orange_distance__distance_pyx, sizeof(__pyx_k_Orange_distance__distance_pyx), 0, 0, 1, 0}, {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, + {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, - {&__pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_k_Users_janez_Dropbox_orange3_Ora, sizeof(__pyx_k_Users_janez_Dropbox_orange3_Ora), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1}, {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, {&__pyx_n_s_any_nan_row, __pyx_k_any_nan_row, sizeof(__pyx_k_any_nan_row), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, {&__pyx_n_s_col1, __pyx_k_col1, sizeof(__pyx_k_col1), 0, 0, 1, 1}, {&__pyx_n_s_col2, __pyx_k_col2, sizeof(__pyx_k_col2), 0, 0, 1, 1}, {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, + {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing, __pyx_k_dist_missing, sizeof(__pyx_k_dist_missing), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing2, __pyx_k_dist_missing2, sizeof(__pyx_k_dist_missing2), 0, 0, 1, 1}, {&__pyx_n_s_dist_missing2_cont, __pyx_k_dist_missing2_cont, sizeof(__pyx_k_dist_missing2_cont), 0, 0, 1, 1}, @@ -23942,6 +25867,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, + {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, + {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_nonnans, __pyx_k_nonnans, sizeof(__pyx_k_nonnans), 0, 0, 1, 1}, {&__pyx_n_s_nonzeros, __pyx_k_nonzeros, sizeof(__pyx_k_nonzeros), 0, 0, 1, 1}, {&__pyx_n_s_nonzeros1, __pyx_k_nonzeros1, sizeof(__pyx_k_nonzeros1), 0, 0, 1, 1}, @@ -23950,16 +25877,26 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_not1_unk2, __pyx_k_not1_unk2, sizeof(__pyx_k_not1_unk2), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, + {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, {&__pyx_n_s_p_nonzero, __pyx_k_p_nonzero, sizeof(__pyx_k_p_nonzero), 0, 0, 1, 1}, {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, + {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 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_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1}, {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, {&__pyx_n_s_row1, __pyx_k_row1, sizeof(__pyx_k_row1), 0, 0, 1, 1}, {&__pyx_n_s_row2, __pyx_k_row2, sizeof(__pyx_k_row2), 0, 0, 1, 1}, + {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, @@ -23968,6 +25905,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, + {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_two_tables, __pyx_k_two_tables, sizeof(__pyx_k_two_tables), 0, 0, 1, 1}, @@ -23979,6 +25917,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_unk1_unk2, __pyx_k_unk1_unk2, sizeof(__pyx_k_unk1_unk2), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, + {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1}, {&__pyx_n_s_val1, __pyx_k_val1, sizeof(__pyx_k_val1), 0, 0, 1, 1}, {&__pyx_n_s_val2, __pyx_k_val2, sizeof(__pyx_k_val2), 0, 0, 1, 1}, @@ -23993,10 +25932,11 @@ static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 20, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 989, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 146, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 149, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error) __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 396, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 425, __pyx_L1_error) __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 599, __pyx_L1_error) __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 818, __pyx_L1_error) return 0; @@ -24008,7 +25948,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -24019,7 +25959,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -24030,7 +25970,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -24041,7 +25981,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -24052,7 +25992,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -24063,7 +26003,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); - /* "../../env/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -24074,49 +26014,80 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - /* "View.MemoryView":131 - * - * if not self.ndim: - * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":989 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * - * if itemsize <= 0: + * cdef inline int import_umath() except -1: */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 131, __pyx_L1_error) + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - /* "View.MemoryView":134 + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":995 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * - * if itemsize <= 0: - * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< - * - * if not isinstance(format, bytes): + * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 134, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - /* "View.MemoryView":137 - * - * if not isinstance(format, bytes): - * format = format.encode('ASCII') # <<<<<<<<<<<<<< - * self._format = format # keep a reference to the byte string - * self.format = self._format + /* "../../miniconda3/envs/o3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 137, __pyx_L1_error) + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 1001, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); - /* "View.MemoryView":146 + /* "View.MemoryView":131 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "View.MemoryView":134 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "View.MemoryView":137 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "View.MemoryView":146 * * if not self._shape: * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< * * */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); /* "View.MemoryView":174 * self.data = malloc(self.len) @@ -24125,9 +26096,9 @@ static int __Pyx_InitCachedConstants(void) { * * if self.dtype_is_object: */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); /* "View.MemoryView":190 * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS @@ -24136,9 +26107,28 @@ static int __Pyx_InitCachedConstants(void) { * info.buf = self.data * info.len = self.len */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); /* "View.MemoryView":484 * result = struct.unpack(self.view.format, bytesitem) @@ -24147,9 +26137,9 @@ static int __Pyx_InitCachedConstants(void) { * else: * if len(self.view.format) == 1: */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 484, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 484, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); /* "View.MemoryView":556 * if self.view.strides == NULL: @@ -24158,9 +26148,9 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 556, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); /* "View.MemoryView":563 * def suboffsets(self): @@ -24169,12 +26159,31 @@ static int __Pyx_InitCachedConstants(void) { * * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) */ - __pyx_tuple__15 = PyTuple_New(1); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); + __pyx_tuple__20 = PyTuple_New(1); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__15, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__15); + PyTuple_SET_ITEM(__pyx_tuple__20, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__20); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); /* "View.MemoryView":668 * if item is Ellipsis: @@ -24183,9 +26192,9 @@ static int __Pyx_InitCachedConstants(void) { * seen_ellipsis = True * else: */ - __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(2, 668, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__16); - __Pyx_GIVEREF(__pyx_slice__16); + __pyx_slice__23 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__23)) __PYX_ERR(2, 668, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__23); + __Pyx_GIVEREF(__pyx_slice__23); /* "View.MemoryView":671 * seen_ellipsis = True @@ -24194,9 +26203,9 @@ static int __Pyx_InitCachedConstants(void) { * have_slices = True * else: */ - __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(2, 671, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__17); - __Pyx_GIVEREF(__pyx_slice__17); + __pyx_slice__24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__24)) __PYX_ERR(2, 671, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__24); + __Pyx_GIVEREF(__pyx_slice__24); /* "View.MemoryView":682 * nslices = ndim - len(result) @@ -24205,9 +26214,9 @@ static int __Pyx_InitCachedConstants(void) { * * return have_slices or nslices, tuple(result) */ - __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(2, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__18); - __Pyx_GIVEREF(__pyx_slice__18); + __pyx_slice__25 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__25)) __PYX_ERR(2, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__25); + __Pyx_GIVEREF(__pyx_slice__25); /* "View.MemoryView":689 * for suboffset in suboffsets[:ndim]: @@ -24216,9 +26225,28 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); + __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__27); + __Pyx_GIVEREF(__pyx_tuple__27); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(2, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); /* "Orange/distance/_distance.pyx":25 * @@ -24227,154 +26255,154 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__20 = PyTuple_Pack(17, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); - __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(6, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_euclidean_rows_discrete, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_tuple__29 = PyTuple_Pack(17, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_dist_missing, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_ival1, __pyx_n_s_ival2); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 25, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); + __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(6, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_euclidean_rows_discrete, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 25, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":59 + /* "Orange/distance/_distance.pyx":57 * * * def fix_euclidean_rows( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__22 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 59, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_tuple__31 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 57, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); + __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_euclidean_rows, 57, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 57, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":92 * * * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__24 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__24); - __Pyx_GIVEREF(__pyx_tuple__24); - __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_rows_normalized, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_tuple__33 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_dist_missing2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_euclidean_rows_normalized, 92, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 92, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":129 + /* "Orange/distance/_distance.pyx":127 * * * def fix_euclidean_cols( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_tuple__26 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__26); - __Pyx_GIVEREF(__pyx_tuple__26); - __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__35); + __Pyx_GIVEREF(__pyx_tuple__35); + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_euclidean_cols, 127, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 127, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":159 + /* "Orange/distance/_distance.pyx":157 * * * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_tuple__28 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__28); - __Pyx_GIVEREF(__pyx_tuple__28); - __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_euclidean_cols_normalized, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(12, __pyx_n_s_distances, __pyx_n_s_x, __pyx_n_s_means, __pyx_n_s_vars, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_euclidean_cols_normalized, 157, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 157, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":186 * * * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables): */ - __pyx_tuple__30 = PyTuple_Pack(13, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); - __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_rows_cont, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(13, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 186, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_manhattan_rows_cont, 186, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 186, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":206 * return distances * * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__32 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing2_cont, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_manhattan_rows, 211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_tuple__41 = PyTuple_Pack(16, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_dist_missing2_cont, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__41); + __Pyx_GIVEREF(__pyx_tuple__41); + __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_manhattan_rows, 206, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 206, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":246 + /* "Orange/distance/_distance.pyx":239 * * * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_tuple__34 = PyTuple_Pack(13, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__34); - __Pyx_GIVEREF(__pyx_tuple__34); - __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_fix_manhattan_rows_normalized, 246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_tuple__43 = PyTuple_Pack(13, __pyx_n_s_distances, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__43); + __Pyx_GIVEREF(__pyx_tuple__43); + __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_fix_manhattan_rows_normalized, 239, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 239, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":269 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=1] medians, * np.ndarray[np.float64_t, ndim=1] mads, */ - __pyx_tuple__36 = PyTuple_Pack(13, __pyx_n_s_x, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__36); - __Pyx_GIVEREF(__pyx_tuple__36); - __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_manhattan_cols, 278, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_tuple__45 = PyTuple_Pack(13, __pyx_n_s_x, __pyx_n_s_medians, __pyx_n_s_mads, __pyx_n_s_normalize, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_d, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__45); + __Pyx_GIVEREF(__pyx_tuple__45); + __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_manhattan_cols, 269, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 269, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":310 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_tuple__38 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__38); - __Pyx_GIVEREF(__pyx_tuple__38); - __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_p_nonzero, 319, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 319, __pyx_L1_error) + __pyx_tuple__47 = PyTuple_Pack(5, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_nonzeros, __pyx_n_s_nonnans, __pyx_n_s_val); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 310, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__47); + __Pyx_GIVEREF(__pyx_tuple__47); + __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_p_nonzero, 310, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 310, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":324 * return float(nonzeros) / nonnans * * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< * cdef: * int row, n_cols, n_rows */ - __pyx_tuple__40 = PyTuple_Pack(6, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_n_cols, __pyx_n_s_n_rows, __pyx_n_s_flags, __pyx_n_s_col); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__40); - __Pyx_GIVEREF(__pyx_tuple__40); - __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_any_nan_row, 333, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 333, __pyx_L1_error) + __pyx_tuple__49 = PyTuple_Pack(6, __pyx_n_s_x, __pyx_n_s_row, __pyx_n_s_n_cols, __pyx_n_s_n_rows, __pyx_n_s_flags, __pyx_n_s_col); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__49); + __Pyx_GIVEREF(__pyx_tuple__49); + __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_any_nan_row, 324, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 324, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":340 * * * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< * np.ndarray[np.int8_t, ndim=2] nonzeros2, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_tuple__42 = PyTuple_Pack(21, __pyx_n_s_nonzeros1, __pyx_n_s_nonzeros2, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_nans1, __pyx_n_s_nans2, __pyx_n_s_ps, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 349, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__42); - __Pyx_GIVEREF(__pyx_tuple__42); - __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(8, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_rows, 349, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 349, __pyx_L1_error) + __pyx_tuple__51 = PyTuple_Pack(21, __pyx_n_s_nonzeros1, __pyx_n_s_nonzeros2, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_nans1, __pyx_n_s_nans2, __pyx_n_s_ps, __pyx_n_s_two_tables, __pyx_n_s_n_rows1, __pyx_n_s_n_rows2, __pyx_n_s_n_cols, __pyx_n_s_row1, __pyx_n_s_row2, __pyx_n_s_col, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 340, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__51); + __Pyx_GIVEREF(__pyx_tuple__51); + __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(8, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_jaccard_rows, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 340, __pyx_L1_error) - /* "Orange/distance/_distance.pyx":425 + /* "Orange/distance/_distance.pyx":416 * * * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x, * np.ndarray[np.int8_t, ndim=1] nans, */ - __pyx_tuple__44 = PyTuple_Pack(23, __pyx_n_s_nonzeros, __pyx_n_s_x, __pyx_n_s_nans, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_in_both, __pyx_n_s_in_any, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 425, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__44); - __Pyx_GIVEREF(__pyx_tuple__44); - __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(4, 0, 23, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_janez_Dropbox_orange3_Ora, __pyx_n_s_jaccard_cols, 425, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 425, __pyx_L1_error) + __pyx_tuple__53 = PyTuple_Pack(23, __pyx_n_s_nonzeros, __pyx_n_s_x, __pyx_n_s_nans, __pyx_n_s_ps, __pyx_n_s_n_rows, __pyx_n_s_n_cols, __pyx_n_s_col1, __pyx_n_s_col2, __pyx_n_s_row, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_intersection, __pyx_n_s_union, __pyx_n_s_ival1, __pyx_n_s_ival2, __pyx_n_s_in_both, __pyx_n_s_in_any, __pyx_n_s_in1_unk2, __pyx_n_s_unk1_in2, __pyx_n_s_unk1_unk2, __pyx_n_s_unk1_not2, __pyx_n_s_not1_unk2, __pyx_n_s_distances); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 416, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__53); + __Pyx_GIVEREF(__pyx_tuple__53); + __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(4, 0, 23, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Orange_distance__distance_pyx, __pyx_n_s_jaccard_cols, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 416, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -24383,9 +26411,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__46); - __Pyx_GIVEREF(__pyx_tuple__46); + __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(2, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__55); + __Pyx_GIVEREF(__pyx_tuple__55); /* "View.MemoryView":283 * @@ -24394,9 +26422,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect = Enum("") * */ - __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(2, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__47); - __Pyx_GIVEREF(__pyx_tuple__47); + __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(2, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__56); + __Pyx_GIVEREF(__pyx_tuple__56); /* "View.MemoryView":284 * cdef generic = Enum("") @@ -24405,9 +26433,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(2, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__48); - __Pyx_GIVEREF(__pyx_tuple__48); + __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(2, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__57); + __Pyx_GIVEREF(__pyx_tuple__57); /* "View.MemoryView":287 * @@ -24416,9 +26444,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect_contiguous = Enum("") * */ - __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(2, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__49); - __Pyx_GIVEREF(__pyx_tuple__49); + __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(2, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__58); + __Pyx_GIVEREF(__pyx_tuple__58); /* "View.MemoryView":288 * @@ -24427,9 +26455,19 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(2, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__50); - __Pyx_GIVEREF(__pyx_tuple__50); + __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(2, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__59); + __Pyx_GIVEREF(__pyx_tuple__59); + + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError + */ + __pyx_tuple__60 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_PickleError, __pyx_n_s_result); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(2, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__60); + __Pyx_GIVEREF(__pyx_tuple__60); + __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -24441,6 +26479,7 @@ static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; @@ -24504,6 +26543,7 @@ PyMODINIT_FUNC PyInit__distance(void) __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif @@ -24542,9 +26582,11 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) __pyx_type___pyx_array.tp_print = 0; if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 103, __pyx_L1_error) __pyx_array_type = &__pyx_type___pyx_array; if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 275, __pyx_L1_error) __pyx_type___pyx_MemviewEnum.tp_print = 0; + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 275, __pyx_L1_error) __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; @@ -24557,6 +26599,7 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) __pyx_type___pyx_memoryview.tp_print = 0; if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 326, __pyx_L1_error) __pyx_memoryview_type = &__pyx_type___pyx_memoryview; __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; @@ -24566,6 +26609,7 @@ PyMODINIT_FUNC PyInit__distance(void) if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) __pyx_type___pyx_memoryviewslice.tp_print = 0; if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 951, __pyx_L1_error) __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", @@ -24606,153 +26650,153 @@ PyMODINIT_FUNC PyInit__distance(void) * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_1euclidean_rows_discrete, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3euclidean_rows_discrete, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_euclidean_rows_discrete, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":59 + /* "Orange/distance/_distance.pyx":57 * * * def fix_euclidean_rows( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_3fix_euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows, __pyx_t_1) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":94 + /* "Orange/distance/_distance.pyx":92 * * * def fix_euclidean_rows_normalized( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_5fix_euclidean_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 94, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":129 + /* "Orange/distance/_distance.pyx":127 * * * def fix_euclidean_cols( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_7fix_euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 129, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols, __pyx_t_1) < 0) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":159 + /* "Orange/distance/_distance.pyx":157 * * * def fix_euclidean_cols_normalized( # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] distances, * np.ndarray[np.float64_t, ndim=2] x, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_9fix_euclidean_cols_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11fix_euclidean_cols_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_euclidean_cols_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":188 + /* "Orange/distance/_distance.pyx":186 * * * def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x2, * char two_tables): */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_11manhattan_rows_cont, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13manhattan_rows_cont, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows_cont, __pyx_t_1) < 0) __PYX_ERR(0, 188, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_rows_cont, __pyx_t_1) < 0) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":211 + /* "Orange/distance/_distance.pyx":206 * return distances * * def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_13fix_manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 211, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows, __pyx_t_1) < 0) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":246 + /* "Orange/distance/_distance.pyx":239 * * * def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x1, * np.ndarray[np.float64_t, ndim=2] x2, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_15fix_manhattan_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17fix_manhattan_rows_normalized, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_manhattan_rows_normalized, __pyx_t_1) < 0) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":278 + /* "Orange/distance/_distance.pyx":269 * * * def manhattan_cols(np.ndarray[np.float64_t, ndim=2] x, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=1] medians, * np.ndarray[np.float64_t, ndim=1] mads, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_17manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_19manhattan_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 278, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_manhattan_cols, __pyx_t_1) < 0) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":319 + /* "Orange/distance/_distance.pyx":310 * * * def p_nonzero(np.ndarray[np.float64_t, ndim=1] x): # <<<<<<<<<<<<<< * cdef: * int row, nonzeros, nonnans */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_19p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_21p_nonzero, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 319, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_p_nonzero, __pyx_t_1) < 0) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":333 + /* "Orange/distance/_distance.pyx":324 * return float(nonzeros) / nonnans * * def any_nan_row(np.ndarray[np.float64_t, ndim=2] x): # <<<<<<<<<<<<<< * cdef: * int row, n_cols, n_rows */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_21any_nan_row, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_23any_nan_row, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_any_nan_row, __pyx_t_1) < 0) __PYX_ERR(0, 333, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_any_nan_row, __pyx_t_1) < 0) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":349 + /* "Orange/distance/_distance.pyx":340 * * * def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, # <<<<<<<<<<<<<< * np.ndarray[np.int8_t, ndim=2] nonzeros2, * np.ndarray[np.float64_t, ndim=2] x1, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_23jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_25jaccard_rows, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 349, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_rows, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "Orange/distance/_distance.pyx":425 + /* "Orange/distance/_distance.pyx":416 * * * def jaccard_cols(np.ndarray[np.int8_t, ndim=2] nonzeros, # <<<<<<<<<<<<<< * np.ndarray[np.float64_t, ndim=2] x, * np.ndarray[np.int8_t, ndim=1] nans, */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_25jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6Orange_8distance_9_distance_27jaccard_cols, NULL, __pyx_n_s_Orange_distance__distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 425, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_jaccard_cols, __pyx_t_1) < 0) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "Orange/distance/_distance.pyx":1 @@ -24774,7 +26818,7 @@ PyMODINIT_FUNC PyInit__distance(void) */ __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 207, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_array_type); @@ -24785,7 +26829,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(generic); __Pyx_DECREF_SET(generic, __pyx_t_1); @@ -24799,7 +26843,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef indirect = Enum("") * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(strided); __Pyx_DECREF_SET(strided, __pyx_t_1); @@ -24813,7 +26857,7 @@ PyMODINIT_FUNC PyInit__distance(void) * * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(indirect); __Pyx_DECREF_SET(indirect, __pyx_t_1); @@ -24827,7 +26871,7 @@ PyMODINIT_FUNC PyInit__distance(void) * cdef indirect_contiguous = Enum("") * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(contiguous); __Pyx_DECREF_SET(contiguous, __pyx_t_1); @@ -24841,7 +26885,7 @@ PyMODINIT_FUNC PyInit__distance(void) * * */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(indirect_contiguous); __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1); @@ -24883,7 +26927,7 @@ PyMODINIT_FUNC PyInit__distance(void) */ __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 535, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 535, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_memoryview_type); @@ -24896,16 +26940,26 @@ PyMODINIT_FUNC PyInit__distance(void) */ __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 981, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 981, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_memoryviewslice_type); - /* "View.MemoryView":1391 - * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * if __pyx_checksum != 0xb068931: + * from pickle import PickleError + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "(tree fragment)":9 + * __pyx_unpickle_Enum__set_state( result, __pyx_state) + * return result + * cdef __pyx_unpickle_Enum__set_state(Enum result, tuple __pyx_state): # <<<<<<<<<<<<<< + * result.name = __pyx_state[0] + * if hasattr(result, '__dict__'): */ /*--- Wrapped vars code ---*/ @@ -24915,7 +26969,7 @@ PyMODINIT_FUNC PyInit__distance(void) __Pyx_XDECREF(__pyx_t_1); if (__pyx_m) { if (__pyx_d) { - __Pyx_AddTraceback("init Orange.distance._distance", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("init Orange.distance._distance", 0, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { @@ -24962,217 +27016,53 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { return result; } -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); +/* None */ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif +/* BufferFormatCheck */ +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; } - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* ArgTypeTest */ -static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (none_allowed && obj == Py_None) return 1; - else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; - #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; - } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); - return 0; -} - -/* BufferFormatCheck */ -static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { - unsigned int n = 1; - return *(unsigned char*)(&n) != 0; -} -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t < '9') { - count *= 10; - count += *t++ - '0'; +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; } } *ts = t; @@ -25816,8 +27706,177 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, } } +/* RaiseArgTupleInvalid */ + static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ + static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ + static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* ArgTypeTest */ + static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; + } + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; +} + /* PyErrFetchRestore */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -25843,7 +27902,7 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject /* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_AVOID_BORROWED_REFS result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); @@ -26078,8 +28137,103 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + return PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + /* BytesEquals */ - static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26097,7 +28251,16 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } else if (length == 1) { return (equals == Py_EQ); } else { - int result = memcmp(ps1, ps2, (size_t)length); + int result; +#if CYTHON_USE_UNICODE_INTERNALS + Py_hash_t hash1, hash2; + hash1 = ((PyBytesObject*)s1)->ob_shash; + hash2 = ((PyBytesObject*)s2)->ob_shash; + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + return (equals == Py_NE); + } +#endif + result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { @@ -26117,7 +28280,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* UnicodeEquals */ - static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { + static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -26157,6 +28320,21 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } +#if CYTHON_USE_UNICODE_INTERNALS + { + Py_hash_t hash1, hash2; + #if CYTHON_PEP393_ENABLED + hash1 = ((PyASCIIObject*)s1)->hash; + hash2 = ((PyASCIIObject*)s2)->hash; + #else + hash1 = ((PyUnicodeObject*)s1)->hash; + hash2 = ((PyUnicodeObject*)s2)->hash; + #endif + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + goto return_ne; + } + } +#endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; @@ -26201,7 +28379,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* GetAttr */ - static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { + static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) @@ -26214,7 +28392,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* decode_c_string */ - static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { @@ -26230,119 +28408,39 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject if (start < 0) { start += length; if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - } - length = stop - start; - if (unlikely(length <= 0)) - return PyUnicode_FromUnicode(NULL, 0); - cstring += start; - if (decode_func) { - return decode_func(cstring, length, errors); - } else { - return PyUnicode_Decode(cstring, length, encoding, errors); - } -} - -/* SaveResetException */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { - PyObject *exc_type = tstate->curexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - return PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { -#endif - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_COMPILING_IN_CPYTHON - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; + start = 0; + } + if (stop < 0) + stop += length; + } + length = stop - start; + if (unlikely(length <= 0)) + return PyUnicode_FromUnicode(NULL, 0); + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* GetAttr3 */ + static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + goto bad; + PyErr_Clear(); + r = d; + Py_INCREF(d); + } + return r; bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; + return NULL; } /* SwapException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -26440,6 +28538,149 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, return module; } +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); + } +} +#endif + /* GetItemInt */ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; @@ -26451,10 +28692,13 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON - if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, i); +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } @@ -26466,10 +28710,13 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON - if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, i); +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } @@ -26481,7 +28728,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { @@ -26522,7 +28769,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, } /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -26535,12 +28782,14 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif - #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; +#ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; +#endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { @@ -26552,58 +28801,74 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); +#endif + + } #endif if (PyFloat_CheckExact(op1)) { @@ -26619,11 +28884,6 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED } #endif -/* None */ - static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { - PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); -} - /* WriteUnraisableException */ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, @@ -26699,13 +28959,18 @@ static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } #endif + if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif } } return __Pyx__PyObject_CallOneArg(func, arg); @@ -26721,8 +28986,40 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } #endif +/* ImportFrom */ + static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* HasAttr */ + static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { + PyObject *r; + if (unlikely(!__Pyx_PyBaseString_Check(n))) { + PyErr_SetString(PyExc_TypeError, + "hasattr(): attribute name must be string"); + return -1; + } + r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + PyErr_Clear(); + return 0; + } else { + Py_DECREF(r); + return 1; + } +} + /* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else @@ -26739,8 +29036,107 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec return -1; } +/* SetupReduce */ + #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; +static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + int ret; + PyObject *name_attr; + name_attr = PyObject_GetAttrString(meth, "__name__"); + if (name_attr) { + ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); + } else { + ret = -1; + } + if (ret < 0) { + PyErr_Clear(); + ret = 0; + } + Py_XDECREF(name_attr); + return ret; +} +static int __Pyx_setup_reduce(PyObject* type_obj) { + int ret = 0; + PyObject* builtin_object = NULL; + static PyObject *object_reduce = NULL; + static PyObject *object_reduce_ex = NULL; + PyObject *reduce = NULL; + PyObject *reduce_ex = NULL; + PyObject *reduce_cython = NULL; + PyObject *setstate = NULL; + PyObject *setstate_cython = NULL; + if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; + if (object_reduce_ex == NULL) { + __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); + __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); + __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); + } + __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); + if (reduce_ex == object_reduce_ex) { + __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); + if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); + ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; + ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; + setstate = PyObject_GetAttrString(type_obj, "__setstate__"); + if (!setstate) PyErr_Clear(); + if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { + __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); + ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; + ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + } + PyType_Modified((PyTypeObject*)type_obj); + } + } + goto GOOD; +BAD: + if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + ret = -1; +GOOD: + Py_XDECREF(builtin_object); + Py_XDECREF(reduce); + Py_XDECREF(reduce_ex); + Py_XDECREF(reduce_cython); + Py_XDECREF(setstate); + Py_XDECREF(setstate_cython); + return ret; +} + +/* CLineInTraceback */ + static int __Pyx_CLineForTraceback(int c_line) { +#ifdef CYTHON_CLINE_IN_TRACEBACK + return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; +#else + PyObject **cython_runtime_dict; + PyObject *use_cline; + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (unlikely(!cython_runtime_dict)) { + PyObject *ptype, *pvalue, *ptraceback; + PyObject *use_cline_obj; + PyErr_Fetch(&ptype, &pvalue, &ptraceback); + use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + use_cline = NULL; + } + PyErr_Restore(ptype, pvalue, ptraceback); + } else { + use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); + } + if (!use_cline) { + c_line = 0; + PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (PyObject_Not(use_cline) != 0) { + c_line = 0; + } + return c_line; +#endif +} + /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; @@ -26820,7 +29216,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -26879,12 +29275,15 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (c_line) { + c_line = __Pyx_CLineForTraceback(c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ @@ -26893,7 +29292,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; - py_frame->f_lineno = py_line; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); @@ -26923,8 +29322,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif - /* MemviewSliceIsContig */ - static int + /* MemviewSliceIsContig */ + static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim) { @@ -26947,7 +29346,7 @@ __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, } /* OverlappingSlices */ - static void + static void __pyx_get_array_memory_extents(__Pyx_memviewslice *slice, void **out_start, void **out_end, int ndim, size_t itemsize) @@ -26983,7 +29382,7 @@ __pyx_slices_overlap(__Pyx_memviewslice *slice1, } /* Capsule */ - static CYTHON_INLINE PyObject * + static CYTHON_INLINE PyObject * __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) { PyObject *cobj; @@ -26996,7 +29395,7 @@ __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) } /* TypeInfoCompare */ - static int + static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) { int i; @@ -27037,7 +29436,7 @@ __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) } /* MemviewSliceValidateAndInit */ - static int + static int __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec) { if (buf->shape[dim] <= 1) @@ -27219,7 +29618,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* ObjectToMemviewSlice */ - static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj) { + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj) { __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_BufFmt_StackElem stack[1]; int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; @@ -27242,7 +29641,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) @@ -27264,7 +29663,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* ObjectToMemviewSlice */ - static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) { + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) { __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_BufFmt_StackElem stack[1]; int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; @@ -27287,7 +29686,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27295,14 +29694,18 @@ static int __Pyx_ValidateAndInit_memviewslice( return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -27314,7 +29717,7 @@ static int __Pyx_ValidateAndInit_memviewslice( } /* MemviewDtypeToObject */ - static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) { + static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) { return (PyObject *) PyFloat_FromDouble(*(double *) itemp); } static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) { @@ -27326,7 +29729,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) { const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27334,14 +29737,18 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o return PyInt_FromLong((long) value); } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(Py_intptr_t) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -27352,8 +29759,8 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } } -/* None */ - #if CYTHON_CCOMPLEX +/* Declarations */ + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); @@ -27372,61 +29779,86 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } #endif -/* None */ - #if CYTHON_CCOMPLEX +/* Arithmetic */ + #if CYTHON_CCOMPLEX #else - static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float denom = b.real * b.real + b.imag * b.imag; - z.real = (a.real * b.real + a.imag * b.imag) / denom; - z.imag = (a.imag * b.real - a.real * b.imag) / denom; - return z; + #if 1 + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabsf(b.real) >= fabsf(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + float r = b.imag / b.real; + float s = 1.0 / (b.real + b.imag * r); + return __pyx_t_float_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + float r = b.real / b.imag; + float s = 1.0 / (b.imag + b.real * r); + return __pyx_t_float_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + float denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_float_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + #endif + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } - static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 - static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { @@ -27444,24 +29876,32 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o case 1: return a; case 2: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(a, a); + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(a, a); case 3: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(z, a); + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, a); case 4: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(z, z); + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; + } else if (b.imag == 0) { + z.real = powf(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2f(0, -1); } - r = a.real; - theta = 0; } else { - r = __Pyx_c_absf(a); + r = __Pyx_c_abs_float(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); @@ -27474,8 +29914,8 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif #endif -/* None */ - #if CYTHON_CCOMPLEX +/* Declarations */ + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); @@ -27494,61 +29934,86 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } #endif -/* None */ - #if CYTHON_CCOMPLEX +/* Arithmetic */ + #if CYTHON_CCOMPLEX #else - static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double denom = b.real * b.real + b.imag * b.imag; - z.real = (a.real * b.real + a.imag * b.imag) / denom; - z.imag = (a.imag * b.real - a.real * b.imag) / denom; - return z; + #if 1 + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs(b.real) >= fabs(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + double r = b.imag / b.real; + double s = 1.0 / (b.real + b.imag * r); + return __pyx_t_double_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + double r = b.real / b.imag; + double s = 1.0 / (b.imag + b.real * r); + return __pyx_t_double_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + double denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_double_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + #endif + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } - static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 - static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { @@ -27566,24 +30031,32 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o case 1: return a; case 2: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(a, a); + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(a, a); case 3: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(z, a); + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, a); case 4: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(z, z); + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; + } else if (b.imag == 0) { + z.real = pow(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2(0, -1); } - r = a.real; - theta = 0; } else { - r = __Pyx_c_abs(a); + r = __Pyx_c_abs_double(a); theta = atan2(a.imag, a.real); } lnr = log(r); @@ -27597,7 +30070,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o #endif /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -27605,14 +30078,18 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -27624,7 +30101,7 @@ static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *o } /* MemviewSliceCopyTemplate */ - static __Pyx_memviewslice + static __Pyx_memviewslice __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, const char *mode, int ndim, size_t sizeof_dtype, int contig_flag, @@ -27691,7 +30168,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { + static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { const char neg_one = (char) -1, const_zero = (char) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -27758,8 +30235,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(char) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -27826,8 +30305,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(char) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -27876,7 +30357,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -27943,8 +30424,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -28011,8 +30494,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -28060,35 +30545,8 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, return (int) -1; } -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -28155,8 +30613,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -28223,8 +30683,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -28272,8 +30734,39 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, return (long) -1; } +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); @@ -28289,7 +30782,7 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -28307,7 +30800,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -28372,7 +30865,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -28397,6 +30890,8 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif if (!*t->p) return -1; + if (PyObject_Hash(*t->p) == -1) + PyErr_Clear(); ++t; } return 0; @@ -28405,11 +30900,11 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { +static CYTHON_INLINE const 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) { +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII @@ -28473,7 +30968,9 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; +#endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 @@ -28482,8 +30979,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; -#if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); @@ -28492,11 +30990,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { name = "long"; res = PyNumber_Long(x); } -#else + #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } + #endif +#else + res = PyNumber_Int(x); #endif if (res) { #if PY_MAJOR_VERSION < 3 diff --git a/Orange/distance/_distance.pyx b/Orange/distance/_distance.pyx index 2c75c01c421..d06af54d1dd 100644 --- a/Orange/distance/_distance.pyx +++ b/Orange/distance/_distance.pyx @@ -15,7 +15,7 @@ cdef extern from "math.h": double sqrt(double x) nogil -cdef void _lower_to_symmetric(double [:, :] distances): +cpdef void lower_to_symmetric(double [:, :] distances): cdef int row1, row2 for row1 in range(distances.shape[0]): for row2 in range(row1): @@ -52,8 +52,6 @@ def euclidean_rows_discrete(np.ndarray[np.float64_t, ndim=2] distances, elif ival1 != ival2: d += 1 distances[row1, row2] += d - if not two_tables: - _lower_to_symmetric(distances) def fix_euclidean_rows( @@ -203,9 +201,6 @@ def manhattan_rows_cont(np.ndarray[np.float64_t, ndim=2] x1, for col in range(n_cols): d += fabs(x1[row1, col] - x2[row2, col]) distances[row1, row2] = d - # TODO: Do this only at the end, not after each function - if not two_tables: - _lower_to_symmetric(distances) return distances def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, @@ -238,8 +233,6 @@ def fix_manhattan_rows(np.ndarray[np.float64_t, ndim=2] distances, else: d += fabs(val1 - val2) distances[row1, row2] = d - if not two_tables: - _lower_to_symmetric(distances) return distances @@ -270,8 +263,6 @@ def fix_manhattan_rows_normalized(np.ndarray[np.float64_t, ndim=2] distances, else: d += fabs(val1 - val2) distances[row1, row2] = d - if not two_tables: - _lower_to_symmetric(distances) return distances @@ -418,7 +409,7 @@ def jaccard_rows(np.ndarray[np.int8_t, ndim=2] nonzeros1, if union != 0: distances[row1, row2] = 1 - intersection / union if not two_tables: - _lower_to_symmetric(distances) + lower_to_symmetric(distances) return distances diff --git a/Orange/distance/distance.py b/Orange/distance/distance.py index f25eae93a6f..bd270de9806 100644 --- a/Orange/distance/distance.py +++ b/Orange/distance/distance.py @@ -74,6 +74,8 @@ def compute_distances(self, x1, x2=None): distances, data1, data2, self.dist_missing_disc, self.dist_missing2_disc, x2 is not None) + if x2 is None: + _distance.lower_to_symmetric(distances) return np.sqrt(distances) @@ -214,6 +216,8 @@ def compute_distances(self, x1, x2): distances, data1, data2, self.dist_missing_disc, self.dist_missing2_disc, x2 is not None) + if x2 is None: + _distance.lower_to_symmetric(distances) return distances