diff --git a/trains/binding/frameworks/lightgbm_bind.py b/trains/binding/frameworks/lightgbm_bind.py index 22d0ec1b..524e8c1f 100644 --- a/trains/binding/frameworks/lightgbm_bind.py +++ b/trains/binding/frameworks/lightgbm_bind.py @@ -118,7 +118,7 @@ class PatchLIGHTgbmModelIO(PatchBaseModelIO): except Exception: pass return callback - + kwargs.setdefault("callbacks", []).append(trains_lightgbm_callback()) ret = original_fn(*args, **kwargs) if not PatchLIGHTgbmModelIO.__main_task: diff --git a/trains/storage/manager.py b/trains/storage/manager.py index ff2a7f82..13d13f8f 100644 --- a/trains/storage/manager.py +++ b/trains/storage/manager.py @@ -1,4 +1,3 @@ -import os import shutil import tarfile from random import random diff --git a/trains/task.py b/trains/task.py index 6a1a0a4c..84be5593 100644 --- a/trains/task.py +++ b/trains/task.py @@ -367,7 +367,7 @@ class Task(_Task): .. code-block:: py - auto_connect_streams={'stdout': True, 'stderr': True`, 'logging': False} + auto_connect_streams={'stdout': True, 'stderr': True, 'logging': False} :return: The main execution Task (Task context). """ diff --git a/trains/utilities/plotlympl/__init__.py b/trains/utilities/plotlympl/__init__.py index 6e7d836b..1e002b4e 100644 --- a/trains/utilities/plotlympl/__init__.py +++ b/trains/utilities/plotlympl/__init__.py @@ -13,3 +13,8 @@ from __future__ import absolute_import from .renderer import PlotlyRenderer from .mplexporter import Exporter + +__all__ = [ + "PlotlyRenderer", + "Exporter" +] diff --git a/trains/utilities/plotlympl/mplexporter/__init__.py b/trains/utilities/plotlympl/mplexporter/__init__.py index 970731c6..60f1582e 100644 --- a/trains/utilities/plotlympl/mplexporter/__init__.py +++ b/trains/utilities/plotlympl/mplexporter/__init__.py @@ -1,2 +1,7 @@ from .renderers import Renderer from .exporter import Exporter + +__all__ = [ + "Renderer", + "Exporter" +] diff --git a/trains/utilities/plotlympl/mplexporter/exporter.py b/trains/utilities/plotlympl/mplexporter/exporter.py index e49fb46d..2e73fe50 100644 --- a/trains/utilities/plotlympl/mplexporter/exporter.py +++ b/trains/utilities/plotlympl/mplexporter/exporter.py @@ -9,9 +9,10 @@ import io from . import utils import matplotlib -from matplotlib import transforms, collections +from matplotlib import transforms, collections # noqa: F401 from matplotlib.backends.backend_agg import FigureCanvasAgg + class Exporter(object): """Matplotlib Exporter @@ -43,7 +44,7 @@ class Exporter(object): # Calling savefig executes the draw() command, putting elements # in the correct place. if fig.canvas is None: - canvas = FigureCanvasAgg(fig) + canvas = FigureCanvasAgg(fig) # noqa: F841 fig.savefig(io.BytesIO(), format='png', dpi=fig.dpi) if self.close_mpl: import matplotlib.pyplot as plt diff --git a/trains/utilities/plotlympl/mplexporter/renderers/__init__.py b/trains/utilities/plotlympl/mplexporter/renderers/__init__.py index ba85b1aa..cb2073b4 100644 --- a/trains/utilities/plotlympl/mplexporter/renderers/__init__.py +++ b/trains/utilities/plotlympl/mplexporter/renderers/__init__.py @@ -10,3 +10,13 @@ from .base import Renderer from .vega_renderer import VegaRenderer, fig_to_vega from .vincent_renderer import VincentRenderer, fig_to_vincent from .fake_renderer import FakeRenderer, FullFakeRenderer + +__all__ = [ + "Renderer", + "VegaRenderer", + "fig_to_vega", + "VincentRenderer", + "fig_to_vincent", + "FakeRenderer", + "FullFakeRenderer" +] diff --git a/trains/utilities/plotlympl/mplexporter/renderers/vega_renderer.py b/trains/utilities/plotlympl/mplexporter/renderers/vega_renderer.py index 82a30bd9..67c8ceb7 100644 --- a/trains/utilities/plotlympl/mplexporter/renderers/vega_renderer.py +++ b/trains/utilities/plotlympl/mplexporter/renderers/vega_renderer.py @@ -14,7 +14,7 @@ class VegaRenderer(Renderer): self.scales = [] self.axes = [] self.marks = [] - + def open_axes(self, ax, props): if len(self.axes) > 0: warnings.warn("multiple axes not yet supported") @@ -24,12 +24,12 @@ class VegaRenderer(Renderer): domain=props['xlim'], type="linear", range="width", - ), + ), dict(name="y", domain=props['ylim'], type="linear", range="height", - ),] + ), ] def draw_line(self, data, coordinates, style, label, mplobj=None): if coordinates != 'data': @@ -51,7 +51,7 @@ class VegaRenderer(Renderer): "strokeWidth": {"value": style['linewidth']}, } } - }) + }) def draw_markers(self, data, coordinates, style, label, mplobj=None): if coordinates != 'data': @@ -75,7 +75,7 @@ class VegaRenderer(Renderer): "strokeWidth": {"value": style['edgewidth']}, } } - }) + }) def draw_text(self, text, position, coordinates, style, text_type=None, mplobj=None): diff --git a/trains/utilities/plotlympl/mplexporter/utils.py b/trains/utilities/plotlympl/mplexporter/utils.py index 261808fa..96b6cb9b 100644 --- a/trains/utilities/plotlympl/mplexporter/utils.py +++ b/trains/utilities/plotlympl/mplexporter/utils.py @@ -28,7 +28,7 @@ def export_color(color): else: c = colorConverter.to_rgba(color) return "rgba(" + ", ".join(str(int(np.round(val * 255))) - for val in c[:3])+', '+str(c[3])+")" + for val in c[:3]) + ', ' + str(c[3]) + ")" def _many_to_one(input_dict): @@ -37,6 +37,7 @@ def _many_to_one(input_dict): for keys, val in input_dict.items() for key in keys) + LINESTYLES = _many_to_one({('solid', '-', (None, None)): 'none', ('dashed', '--'): "6,6", ('dotted', ':'): "2,2", @@ -179,7 +180,7 @@ def get_text_style(text): style['color'] = export_color(text.get_color()) style['halign'] = text.get_horizontalalignment() # left, center, right style['valign'] = text.get_verticalalignment() # baseline, center, top - style['malign'] = text._multialignment # text alignment when '\n' in text + style['malign'] = text._multialignment # text alignment when '\n' in text style['rotation'] = text.get_rotation() style['zorder'] = text.get_zorder() return style @@ -269,7 +270,7 @@ def get_axes_properties(ax): 'dynamic': ax.get_navigate(), 'axison': ax.axison, 'frame_on': ax.get_frame_on(), - 'patch_visible':ax.patch.get_visible(), + 'patch_visible': ax.patch.get_visible(), 'axes': [get_axis_properties(ax.xaxis), get_axis_properties(ax.yaxis)]} diff --git a/trains/utilities/plotlympl/mpltools.py b/trains/utilities/plotlympl/mpltools.py index a756ebdc..36133219 100644 --- a/trains/utilities/plotlympl/mpltools.py +++ b/trains/utilities/plotlympl/mpltools.py @@ -83,7 +83,7 @@ def convert_dash(mpl_dash): def convert_path(path): - verts = path[0] # may use this later + verts = path[0] # noqa: F841, may use this later code = tuple(path[1]) if code in PATH_MAP: return PATH_MAP[code] @@ -118,7 +118,7 @@ def hex_to_rgb(value): """ value = value.lstrip("#") lv = len(value) - return tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3)) + return tuple(int(value[i: i + lv // 3], 16) for i in range(0, lv, lv // 3)) def merge_color_and_opacity(color, opacity): @@ -542,7 +542,7 @@ def mpl_dates_to_datestrings(dates, mpl_formatter): try: dates = matplotlib.dates.epoch2num([date * 24 * 60 * 60 for date in dates]) dates = matplotlib.dates.num2date(dates) - except: + except: # noqa: E722 return _dates # the rest of mpl dates are in floating point days since @@ -551,7 +551,7 @@ def mpl_dates_to_datestrings(dates, mpl_formatter): else: try: dates = matplotlib.dates.num2date(dates) - except: + except: # noqa: E722 return _dates time_stings = [