From b7546d61a9d701644c1edd8dde1c2626d5507789 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 28 May 2018 16:46:33 +0200 Subject: [PATCH 1/2] python2 compatibility fixes - initialized keyword(s) not allowed after *args in python2.x use general **kw instead Signed-off-by: Thorsten Liebig --- smithplot/smithaxes.py | 8 ++++++-- smithplot/smithhelper.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/smithplot/smithaxes.py b/smithplot/smithaxes.py index 2ed8cbb..7777b65 100644 --- a/smithplot/smithaxes.py +++ b/smithplot/smithaxes.py @@ -36,6 +36,8 @@ parameters are array-like types (e.g. numpy.ndarray). ''' +from __future__ import division, print_function, unicode_literals + from collections import Iterable from numbers import Number from types import MethodType, FunctionType @@ -558,7 +560,7 @@ def end_pan(self): def drag_pan(self, button, key, x, y): pass - def _moebius_z(self, *args, normalize=None): + def _moebius_z(self, *args, **kw): ''' Basic transformation. @@ -581,11 +583,12 @@ def _moebius_z(self, *args, normalize=None): Performs w = (z - k) / (z + k) with k = 'axes.scale' Type: Complex number or numpy.ndarray with dtype=complex ''' + normalize = kw.get('normalize', None) normalize = self._normalize if normalize is None else normalize norm = 1 if normalize else self._impedance return smithhelper.moebius_z(*args, norm=norm) - def _moebius_inv_z(self, *args, normalize=None): + def _moebius_inv_z(self, *args, **kw): ''' Basic inverse transformation. @@ -608,6 +611,7 @@ def _moebius_inv_z(self, *args, normalize=None): Performs w = k * (1 - z) / (1 + z) with k = 'axes.scale' Type: Complex number or numpy.ndarray with dtype=complex ''' + normalize = kw.get('normalize', None) normalize = self._normalize if normalize is None else normalize norm = 1 if normalize else self._impedance return smithhelper.moebius_inv_z(*args, norm=norm) diff --git a/smithplot/smithhelper.py b/smithplot/smithhelper.py index cba2199..f4b89fb 100644 --- a/smithplot/smithhelper.py +++ b/smithplot/smithhelper.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # last edit: 11.04.2018 +from __future__ import division, print_function, unicode_literals + from collections import Iterable import numpy as np @@ -38,13 +40,15 @@ def z_to_xy(z): return z.real, z.imag -def moebius_z(*args, norm): +def moebius_z(*args, **kw): z = xy_to_z(*args) + norm = kw['norm'] return 1 - 2 * norm / (z + norm) -def moebius_inv_z(*args, norm): +def moebius_inv_z(*args, **kw): z = xy_to_z(*args) + norm = kw['norm'] return norm * (1 + z) / (1 - z) From f5b2cf6dfd211bc71829f8d0415be85d7d482d8b Mon Sep 17 00:00:00 2001 From: Juan Osorio Date: Wed, 26 Feb 2020 20:35:33 +0100 Subject: [PATCH 2/2] Add type to d_mat , np.linspace requires a np.int --- smithplot/smithaxes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithplot/smithaxes.py b/smithplot/smithaxes.py index 7777b65..ac4fe98 100644 --- a/smithplot/smithaxes.py +++ b/smithplot/smithaxes.py @@ -1009,7 +1009,7 @@ def draw_nonfancy(grid): len_x, len_y = len(xticks) - 1, len(yticks) - 1 # 2. Step: calculate optimal gridspacing for each quadrant - d_mat = np.ones((len_x, len_y, 2)) + d_mat = np.ones((len_x, len_y, 2), dtype=np.int) # TODO: optimize spacing algorithm for i in range(len_x):