From 65f202e50e9ae27798099dedcabed21b91f58ca8 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 20:18:45 +0100 Subject: [PATCH 01/11] restyling --- src/urh/SceneManager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/urh/SceneManager.py b/src/urh/SceneManager.py index 57a737a760..96d5b3c811 100644 --- a/src/urh/SceneManager.py +++ b/src/urh/SceneManager.py @@ -15,8 +15,8 @@ def __init__(self, parent): super().__init__(parent) self.scene = ZoomableScene() self.plot_data = np.array([0] * 100) - self.line_item = self.scene.addLine(0, 0, 0, 0, QPen(constants.AXISCOLOR, Qt.FlatCap)) - self.text_item = self.scene.addText("", QFont("Helvetica", 20)) + self.line_item = self.scene.addLine(0, 0, 0, 0, QPen(constants.AXISCOLOR, Qt.FlatCap)) + self.text_item = self.scene.addText("", QFont("Helvetica", 20)) self.minimum = float("nan") # NaN = AutoDetect self.maximum = float("nan") # NaN = AutoDetect @@ -38,7 +38,7 @@ def show_scene_section(self, x1: float, x2: float, subpath_ranges=None, colors=N :return: """ paths = path_creator.create_path(self.plot_data, start=self.__limit_value(x1), end=self.__limit_value(x2), - subpath_ranges=subpath_ranges) + subpath_ranges=subpath_ranges) self.set_path(paths, colors=colors) def set_path(self, paths: list, colors=None): @@ -46,10 +46,10 @@ def set_path(self, paths: list, colors=None): colors = [constants.LINECOLOR] * len(paths) if colors is None else colors assert len(paths) == len(colors) for path, color in zip(paths, colors): - self.scene.addPath(path, QPen(color if color else constants.LINECOLOR, Qt.FlatCap)) + self.scene.addPath(path, QPen(color if color else constants.LINECOLOR, Qt.FlatCap)) def __limit_value(self, val: float) -> int: - return 0 if val < 0 else self.num_samples if val > self.num_samples else int(val) + return 0 if val < 0 else self.num_samples if val > self.num_samples else int(val) def show_full_scene(self): self.show_scene_section(0, self.num_samples) @@ -66,8 +66,8 @@ def init_scene(self): minimum, maximum = self.minimum, self.maximum if abs(minimum) > abs(maximum): - minimum = -self.padding*abs(minimum) - maximum = -self.padding*minimum + minimum = -self.padding * abs(minimum) + maximum = -self.padding * minimum else: maximum = abs(maximum) minimum = -maximum From 6b9715a1399cdf5cc3d3699f970e664d662c0d20 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 20:45:06 +0100 Subject: [PATCH 02/11] fix floating error for subpath range calculation --- src/urh/cythonext/path_creator.cpp | 289 ++++++++++++++--------------- src/urh/cythonext/path_creator.pyx | 6 +- 2 files changed, 146 insertions(+), 149 deletions(-) diff --git a/src/urh/cythonext/path_creator.cpp b/src/urh/cythonext/path_creator.cpp index 4c498ae0de..e39b6e49f9 100644 --- a/src/urh/cythonext/path_creator.cpp +++ b/src/urh/cythonext/path_creator.cpp @@ -1345,14 +1345,6 @@ 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); -/* PyIntBinop.proto */ -#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)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { @@ -1562,6 +1554,14 @@ static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif +/* PyIntBinop.proto */ +#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)\ + (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 @@ -2403,7 +2403,7 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m * if samples_per_pixel > 1: * sample_rng = np.arange(start, end, samples_per_pixel, dtype=np.int64) # <<<<<<<<<<<<<< * values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") - * scale_factor = num_samples / (2 * len(sample_rng)) + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); @@ -2452,7 +2452,7 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m * if samples_per_pixel > 1: * sample_rng = np.arange(start, end, samples_per_pixel, dtype=np.int64) * values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") # <<<<<<<<<<<<<< - * scale_factor = num_samples / (2 * len(sample_rng)) + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! * for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error) @@ -2496,7 +2496,7 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m /* "src/urh/cythonext/path_creator.pyx":30 * sample_rng = np.arange(start, end, samples_per_pixel, dtype=np.int64) * values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") - * scale_factor = num_samples / (2 * len(sample_rng)) # <<<<<<<<<<<<<< + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! # <<<<<<<<<<<<<< * for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): * chunk_end = i + samples_per_pixel */ @@ -2504,11 +2504,11 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_scale_factor = (__pyx_v_num_samples / ((PY_LONG_LONG)(2 * __pyx_t_9))); + __pyx_v_scale_factor = (((double)__pyx_v_num_samples) / (2.0 * __pyx_t_9)); /* "src/urh/cythonext/path_creator.pyx":31 * values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") - * scale_factor = num_samples / (2 * len(sample_rng)) + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! * for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): # <<<<<<<<<<<<<< * chunk_end = i + samples_per_pixel * if chunk_end >= end: @@ -2553,7 +2553,7 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m __pyx_v_tmp = ((float)__PYX_NAN()); /* "src/urh/cythonext/path_creator.pyx":32 - * scale_factor = num_samples / (2 * len(sample_rng)) + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! * for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): * chunk_end = i + samples_per_pixel # <<<<<<<<<<<<<< * if chunk_end >= end: @@ -2740,7 +2740,7 @@ static PyObject *__pyx_f_3src_3urh_9cythonext_12path_creator_create_path(__Pyx_m /* "src/urh/cythonext/path_creator.pyx":31 * values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") - * scale_factor = num_samples / (2 * len(sample_rng)) + * scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! * for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): # <<<<<<<<<<<<<< * chunk_end = i + samples_per_pixel * if chunk_end >= end: @@ -2968,7 +2968,7 @@ __pyx_v_values = __pyx_t_10; * scale_factor = 1 # prevent division by zero * for subpath_range in subpath_ranges: # <<<<<<<<<<<<<< * substart = int((subpath_range[0]-start)/scale_factor) - * subend = int((subpath_range[1]-start)/scale_factor) + 1 + * subend = int((subpath_range[1]-start)/scale_factor) */ if (unlikely(__pyx_v_subpath_ranges == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); @@ -2990,7 +2990,7 @@ __pyx_v_values = __pyx_t_10; * scale_factor = 1 # prevent division by zero * for subpath_range in subpath_ranges: * substart = int((subpath_range[0]-start)/scale_factor) # <<<<<<<<<<<<<< - * subend = int((subpath_range[1]-start)/scale_factor) + 1 + * subend = int((subpath_range[1]-start)/scale_factor) * result.append(array_to_QPath(x[substart:subend], values[substart:subend])) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_subpath_range, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) @@ -3016,7 +3016,7 @@ __pyx_v_values = __pyx_t_10; /* "src/urh/cythonext/path_creator.pyx":62 * for subpath_range in subpath_ranges: * substart = int((subpath_range[0]-start)/scale_factor) - * subend = int((subpath_range[1]-start)/scale_factor) + 1 # <<<<<<<<<<<<<< + * subend = int((subpath_range[1]-start)/scale_factor) # <<<<<<<<<<<<<< * result.append(array_to_QPath(x[substart:subend], values[substart:subend])) * return result */ @@ -3037,15 +3037,12 @@ __pyx_v_values = __pyx_t_10; __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_subend, __pyx_t_4); - __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_subend, __pyx_t_1); + __pyx_t_1 = 0; /* "src/urh/cythonext/path_creator.pyx":63 * substart = int((subpath_range[0]-start)/scale_factor) - * subend = int((subpath_range[1]-start)/scale_factor) + 1 + * subend = int((subpath_range[1]-start)/scale_factor) * result.append(array_to_QPath(x[substart:subend], values[substart:subend])) # <<<<<<<<<<<<<< * return result * @@ -3096,29 +3093,29 @@ __pyx_t_22 = __Pyx_PyIndex_AsSsize_t(__pyx_v_substart); if (unlikely((__pyx_t_22 __PYX_ERR(0, 63, __pyx_L1_error) } -__pyx_t_4 = __pyx_f_3src_3urh_9cythonext_12path_creator_array_to_QPath(__pyx_t_20, __pyx_t_10, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); +__pyx_t_1 = __pyx_f_3src_3urh_9cythonext_12path_creator_array_to_QPath(__pyx_t_20, __pyx_t_10, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); __pyx_t_20.memview = NULL; __pyx_t_20.data = NULL; __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL; - __pyx_t_23 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_23 == -1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_23 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_23 == -1)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "src/urh/cythonext/path_creator.pyx":60 * if scale_factor == 0: * scale_factor = 1 # prevent division by zero * for subpath_range in subpath_ranges: # <<<<<<<<<<<<<< * substart = int((subpath_range[0]-start)/scale_factor) - * subend = int((subpath_range[1]-start)/scale_factor) + 1 + * subend = int((subpath_range[1]-start)/scale_factor) */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "src/urh/cythonext/path_creator.pyx":64 - * subend = int((subpath_range[1]-start)/scale_factor) + 1 + * subend = int((subpath_range[1]-start)/scale_factor) * result.append(array_to_QPath(x[substart:subend], values[substart:subend])) * return result # <<<<<<<<<<<<<< * @@ -21066,122 +21063,6 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } -/* PyIntBinop */ - #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))) { - 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 - 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)) { - 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; -#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)) { - 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 - /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, @@ -22211,6 +22092,122 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, return module; } +/* PyIntBinop */ + #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))) { + 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 + 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)) { + 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; +#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)) { + 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); diff --git a/src/urh/cythonext/path_creator.pyx b/src/urh/cythonext/path_creator.pyx index 96320ad73f..8d743b4c0b 100644 --- a/src/urh/cythonext/path_creator.pyx +++ b/src/urh/cythonext/path_creator.pyx @@ -27,7 +27,7 @@ cpdef create_path(float[:] samples, long long start, long long end, list subpath if samples_per_pixel > 1: sample_rng = np.arange(start, end, samples_per_pixel, dtype=np.int64) values = np.zeros(2 * len(sample_rng), dtype=np.float32, order="C") - scale_factor = num_samples / (2 * len(sample_rng)) + scale_factor = num_samples / (2.0 * len(sample_rng)) # 2.0 is important to make it a float division! for i in prange(start, end, samples_per_pixel, nogil=True, schedule='static'): chunk_end = i + samples_per_pixel if chunk_end >= end: @@ -59,7 +59,7 @@ cpdef create_path(float[:] samples, long long start, long long end, list subpath scale_factor = 1 # prevent division by zero for subpath_range in subpath_ranges: substart = int((subpath_range[0]-start)/scale_factor) - subend = int((subpath_range[1]-start)/scale_factor) + 1 + subend = int((subpath_range[1]-start)/scale_factor) result.append(array_to_QPath(x[substart:subend], values[substart:subend])) return result @@ -106,4 +106,4 @@ cpdef array_to_QPath(np.int64_t[:] x, float[:] y): ds = QDataStream(buf) ds >> path - return path \ No newline at end of file + return path From 0d6fc763ed810f42c795bb50734d78b4aa6a1e4f Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 21:04:23 +0100 Subject: [PATCH 03/11] remove scene creator call in graphic view to prevent flickering when zooming --- src/urh/ui/views/EpicGraphicView.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/urh/ui/views/EpicGraphicView.py b/src/urh/ui/views/EpicGraphicView.py index 1e2c65c3c7..e17dbecc7e 100644 --- a/src/urh/ui/views/EpicGraphicView.py +++ b/src/urh/ui/views/EpicGraphicView.py @@ -310,13 +310,11 @@ def keyPressEvent(self, event: QKeyEvent): self.horizontalScrollBar().setValue(cur_val - step) def draw_full_signal(self): - if hasattr(self.parent_frame, "scene_creator"): - self.parent_frame.scene_creator.show_full_scene() - y_factor = self.transform().m22() - self.resetTransform() - x_factor = self.width() / self.sceneRect().width() - self.scale(x_factor, y_factor) - self.centerOn(0, self.y_center) + y_factor = self.transform().m22() + self.resetTransform() + x_factor = self.width() / self.sceneRect().width() + self.scale(x_factor, y_factor) + self.centerOn(0, self.y_center) def zoom_to_selection(self, start: int, end: int): if start == end: From 02d9457ed3adf84596ede8981faf289208e1390e Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 21:12:11 +0100 Subject: [PATCH 04/11] set redraw timer interval to 1 for smoother zoom --- src/urh/controller/SignalFrameController.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/urh/controller/SignalFrameController.py b/src/urh/controller/SignalFrameController.py index ecb2c63af2..b90a67aeea 100644 --- a/src/urh/controller/SignalFrameController.py +++ b/src/urh/controller/SignalFrameController.py @@ -70,7 +70,7 @@ def __init__(self, proto_analyzer: ProtocolAnalyzer, undo_stack: QUndoStack, self.redraw_timer = QTimer() self.redraw_timer.setSingleShot(True) - self.redraw_timer.setInterval(100) + self.redraw_timer.setInterval(1) self.proto_selection_timer = QTimer() # For Update Proto Selection from ROI self.proto_selection_timer.setSingleShot(True) From d76b340961ca5d7043bb33ddc799c34d77e1e564 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 21:13:12 +0100 Subject: [PATCH 05/11] set redraw timer interval to 10 for smooth zoom and good performance --- src/urh/controller/SignalFrameController.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/urh/controller/SignalFrameController.py b/src/urh/controller/SignalFrameController.py index b90a67aeea..ad10f7431e 100644 --- a/src/urh/controller/SignalFrameController.py +++ b/src/urh/controller/SignalFrameController.py @@ -70,7 +70,7 @@ def __init__(self, proto_analyzer: ProtocolAnalyzer, undo_stack: QUndoStack, self.redraw_timer = QTimer() self.redraw_timer.setSingleShot(True) - self.redraw_timer.setInterval(1) + self.redraw_timer.setInterval(10) self.proto_selection_timer = QTimer() # For Update Proto Selection from ROI self.proto_selection_timer.setSingleShot(True) From 64beec695235728e669fea584566e63e7622b9d8 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Tue, 7 Feb 2017 21:20:02 +0100 Subject: [PATCH 06/11] rename test to prevent travis from random failing --- .../{test_generator_table.py => TestGeneratorTablePerformance.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_generator_table.py => TestGeneratorTablePerformance.py} (100%) diff --git a/tests/test_generator_table.py b/tests/TestGeneratorTablePerformance.py similarity index 100% rename from tests/test_generator_table.py rename to tests/TestGeneratorTablePerformance.py From 49a4e1995d59ce901f89ad238bbfa3d15394fc41 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Wed, 8 Feb 2017 06:45:41 +0100 Subject: [PATCH 07/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0453480d1..37a2178955 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ sudo pip3 install urh ### Windows 1. Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools). -2. Install [Python 3.5 for Windows](https://www.python.org/downloads/windows/). +2. Install [Pythob for Windows](https://www.python.org/downloads/windows/). 3. (Optional) Open a terminal (__cmd__) and type: ``` pip install numpy ``` - _This speeds the installation up a bit._ 4. In a terminal, type: ``` pip install urh ```. 5. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar. From 0c46e95a4d1eb7a187640e0475499e1e79d6b4b5 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Wed, 8 Feb 2017 06:46:06 +0100 Subject: [PATCH 08/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37a2178955..56f44a701f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ sudo pip3 install urh ### Windows 1. Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools). -2. Install [Pythob for Windows](https://www.python.org/downloads/windows/). +2. Install [Python for Windows](https://www.python.org/downloads/windows/). 3. (Optional) Open a terminal (__cmd__) and type: ``` pip install numpy ``` - _This speeds the installation up a bit._ 4. In a terminal, type: ``` pip install urh ```. 5. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar. From f77dd2a7329cce33a6c609d4c74f6d5f275c0e9a Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Wed, 8 Feb 2017 06:46:41 +0100 Subject: [PATCH 09/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56f44a701f..7a776e50cb 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ sudo pip3 install urh ### Windows 1. Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools). -2. Install [Python for Windows](https://www.python.org/downloads/windows/). +2. Install [Python 3 for Windows](https://www.python.org/downloads/windows/). 3. (Optional) Open a terminal (__cmd__) and type: ``` pip install numpy ``` - _This speeds the installation up a bit._ 4. In a terminal, type: ``` pip install urh ```. 5. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar. From 9b97d60c4de60d83419bb0d5b5850b824e91b378 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Wed, 8 Feb 2017 06:46:58 +0100 Subject: [PATCH 10/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a776e50cb..cd799d7595 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ sudo pip3 install urh 5. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar. ### Mac OS X -1. Install [Python for Mac OS X](https://www.python.org/downloads/mac-osx/). +1. Install [Python 3 for Mac OS X](https://www.python.org/downloads/mac-osx/). 2. In a terminal, type: ``` pip3 install urh ```. 3. Type ``` urh ``` in a terminal to get it started. From 0d3163f7c4b87eda329c5f56743d0df34c3b87b3 Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Thu, 9 Feb 2017 07:24:48 +0100 Subject: [PATCH 11/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd799d7595..f2b4d9f0ab 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/jopohl/urh.svg?branch=master)](https://travis-ci.org/jopohl/urh) +# Universal Radio Hacker [![Build Status](https://travis-ci.org/jopohl/urh.svg?branch=master)](https://travis-ci.org/jopohl/urh) ## What's this? Universal Radio Hacker is a suite for investigating unknown wireless protocols. Features include