From dbdd7b4540d77ce46afeeea904d3d7fa6d993deb Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Thu, 6 Nov 2025 17:37:02 +0100 Subject: [PATCH] fixed linter errors and ambigious variable names --- pygrace/__init__.py | 1 - pygrace/colors.py | 5 ++--- pygrace/pygrace.py | 6 +++--- setup.py | 13 ------------- tudplot/__init__.py | 3 +-- tudplot/altair.py | 6 ++---- tudplot/tud.py | 1 - tudplot/utils.py | 7 +++---- tudplot/xmgrace.py | 4 ++-- 9 files changed, 13 insertions(+), 33 deletions(-) delete mode 100644 setup.py diff --git a/pygrace/__init__.py b/pygrace/__init__.py index b91cf25..e69de29 100644 --- a/pygrace/__init__.py +++ b/pygrace/__init__.py @@ -1 +0,0 @@ -from .pygrace import saveagr \ No newline at end of file diff --git a/pygrace/colors.py b/pygrace/colors.py index 11a534c..d1fb4eb 100644 --- a/pygrace/colors.py +++ b/pygrace/colors.py @@ -1,5 +1,4 @@ import matplotlib as mpl -import matplotlib.pyplot as plt import numpy as np from collections import OrderedDict from itertools import cycle @@ -10,9 +9,9 @@ def make_cmap(colors, mapping=True): colors = np.array(colors.values()) bit_rgb = np.linspace(0, 1, 256) position = np.linspace(0, 1, len(colors)) - _cols = colors[:] + 0 + _cols = colors[:] + 0 for i in range(len(colors)): - for j in xrange(3): + for j in range(3): _cols[i][j] = bit_rgb[colors[i][j]] if mapping: cdict = {'red': [], 'green':[], 'blue':[]} diff --git a/pygrace/pygrace.py b/pygrace/pygrace.py index 54f29f3..8207739 100644 --- a/pygrace/pygrace.py +++ b/pygrace/pygrace.py @@ -263,13 +263,13 @@ legend char size {legend_fontsize} getattr(self, d)() sanitize_strings(self.__dict__) - self.lines = {'s{}'.format(i): AgrLine(l, self) for i, l in enumerate(axis.lines)} + self.lines = {'s{}'.format(i): AgrLine(line, self) for i, line in enumerate(axis.lines)} self.texts = [AgrText(t, self) for t in self.axis.texts] def __str__(self): o = self.fmt.format(**self.__dict__) - for k, l in self.lines.items(): - o += textwrap.indent(str(l), prefix=k + ' ') + for k, line in self.lines.items(): + o += textwrap.indent(str(line), prefix=k + ' ') for txt in self.texts: o += 'with string\n' o += textwrap.indent(str(txt), prefix=' ') diff --git a/setup.py b/setup.py deleted file mode 100644 index bcc47c0..0000000 --- a/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -from setuptools import setup - -setup( - name='tudplot', - description='Matplotlib styling in TU Darmstadt corporate design', - author_email='niels.mueller@physik.tu-darmstadt.de', - - packages=['tudplot', 'pygrace'], - version='0.1', - requires=['matplotlib'], - package_data={'tudplot': ['tud.mplstyle']}, - zip_safe=False, -) diff --git a/tudplot/__init__.py b/tudplot/__init__.py index 25f6b82..07739b8 100755 --- a/tudplot/__init__.py +++ b/tudplot/__init__.py @@ -5,9 +5,8 @@ import matplotlib as mpl from matplotlib import pyplot from cycler import cycler -from .xmgrace import export_to_agr, load_agr_data +from .xmgrace import export_to_agr from .tud import tudcolors, nominal_colors, sequential_colors -from .utils import facet_plot, CurvedText as curved_text def activate(scheme='b', full=False, sequential=False, cmap='blue-red', **kwargs): diff --git a/tudplot/altair.py b/tudplot/altair.py index 1da9739..4578fd4 100755 --- a/tudplot/altair.py +++ b/tudplot/altair.py @@ -1,8 +1,6 @@ import altair -from altair import Config, Color, Shape, Column, Row, Encoding, Scale, Axis -from random import randint -import os +from altair import Encoding import logging import matplotlib.pyplot as plt @@ -90,7 +88,7 @@ class Chart(altair.Chart): def to_mpl(self): d = self.to_dict() - fmt = 'o' if d.get('mark', 'point') is 'point' else '-' + fmt = 'o' if d.get('mark', 'point') == 'point' else '-' def encode(data, encoding, **kwargs): logging.debug(str(kwargs)) diff --git a/tudplot/tud.py b/tudplot/tud.py index 8df1133..b01c7f7 100644 --- a/tudplot/tud.py +++ b/tudplot/tud.py @@ -1,4 +1,3 @@ -import re import matplotlib as mpl import numpy diff --git a/tudplot/utils.py b/tudplot/utils.py index 11a022f..b264e86 100644 --- a/tudplot/utils.py +++ b/tudplot/utils.py @@ -1,7 +1,6 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl -from collections.abc import Iterable from matplotlib.cbook import flatten from itertools import cycle @@ -48,8 +47,8 @@ def facet_plot(dframe, facets, props, ydata, layout=None, newfig=True, figsize=N plot_kwargs = kwargs.copy() for k in ['logx', 'logy', 'loglog']: plot_kwargs.pop(k, None) - for l, p in prop_styles.items(): - ax0.plot([], label=str(l), **p, **plot_kwargs) + for label, p in prop_styles.items(): + ax0.plot([], label=str(label), **p, **plot_kwargs) ax0.legend(loc='center left', bbox_to_anchor=(1, 0.5), fontsize='x-small') for ax, (ps, df) in zip(flatten(axs), dframe.groupby(facets, squeeze=False)): for prop, df_prop in df.groupby(props): @@ -130,7 +129,7 @@ class CurvedText(mpl.text.Text): # points of the curve in figure coordinates: x_fig,y_fig = ( - np.array(l) for l in zip(*self.axes.transData.transform([ + np.array(line) for line in zip(*self.axes.transData.transform([ (i,j) for i,j in zip(self.__x,self.__y) ])) ) diff --git a/tudplot/xmgrace.py b/tudplot/xmgrace.py index 8833d96..dcc3658 100755 --- a/tudplot/xmgrace.py +++ b/tudplot/xmgrace.py @@ -70,7 +70,7 @@ def get_major_ticks(dim): def get_major_dticks(axis): ticks = getattr(axis, 'get_{}ticks'.format(dim))() scale = getattr(axis, 'get_{}scale'.format(dim))() - if scale is 'log': + if scale == 'log': value = (ticks[1:] / ticks[:-1]).mean() else: value = (ticks[1:] - ticks[:-1]).mean() @@ -406,7 +406,7 @@ def export_to_agr(figure, filename, **kwargs): for i, color in enumerate(ValueAttribute.attr_lists['color']): # print(i, color) - if color is not 'none': + if color != 'none': rgba, = cc.to_rgba_array(color) rgb_tuple = tuple(int(255 * c) for c in rgba[:3]) color_name = tudcol_rev.get(tuple(rgba), color)