From 024c41824cc21c530d2615ba8df4e2fb8fe7a831 Mon Sep 17 00:00:00 2001 From: sunhailinLeo <379978424@qq.com> Date: Thu, 6 Apr 2023 17:04:24 +0800 Subject: [PATCH] code format --- pyecharts/charts/base.py | 14 +- pyecharts/charts/basic_charts/calendar.py | 6 +- pyecharts/charts/basic_charts/geo.py | 6 +- pyecharts/charts/basic_charts/heatmap.py | 6 +- pyecharts/charts/basic_charts/kline.py | 6 +- pyecharts/charts/basic_charts/liquid.py | 6 +- pyecharts/charts/basic_charts/parallel.py | 6 +- pyecharts/charts/basic_charts/polar.py | 10 +- pyecharts/charts/basic_charts/radar.py | 1 - pyecharts/charts/basic_charts/sankey.py | 2 +- pyecharts/charts/basic_charts/wordcloud.py | 10 +- pyecharts/charts/chart.py | 47 +- pyecharts/charts/composite_charts/grid.py | 6 +- pyecharts/charts/composite_charts/timeline.py | 8 +- pyecharts/charts/three_axis_charts/bar3D.py | 6 +- .../charts/three_axis_charts/graph_gl.py | 6 +- pyecharts/charts/three_axis_charts/line3D.py | 6 +- pyecharts/charts/three_axis_charts/lines3D.py | 6 +- pyecharts/charts/three_axis_charts/map3D.py | 6 +- .../charts/three_axis_charts/map_globe.py | 6 +- .../charts/three_axis_charts/scatter3D.py | 6 +- .../charts/three_axis_charts/surface3D.py | 6 +- pyecharts/options/global_options.py | 10 +- pyecharts/render/display.py | 6 +- pyecharts/render/engine.py | 1 + test.py | 6 +- test/__init__.py | 2 +- test/test_base.py | 10 +- test/test_calendar.py | 37 +- test/test_chart.py | 2 +- test/test_custom.py | 15 +- test/test_datasets.py | 4 +- test/test_exception.py | 2 +- test/test_faker.py | 1 - test/test_geo.py | 761 ++++-------------- test/test_global_options.py | 13 +- test/test_graph_gl.py | 38 +- test/test_graphic.py | 12 +- test/test_grid.py | 18 +- test/test_kline.py | 3 +- test/test_lines3d.py | 3 +- test/test_map.py | 761 ++++-------------- test/test_page.py | 4 +- test/test_parallel.py | 2 +- test/test_series_options.py | 35 +- test/test_snapshot.py | 4 +- test/test_tab.py | 10 +- test/test_utils.py | 9 +- 48 files changed, 520 insertions(+), 1431 deletions(-) diff --git a/pyecharts/charts/base.py b/pyecharts/charts/base.py index 2a96c065..a1cc49a2 100644 --- a/pyecharts/charts/base.py +++ b/pyecharts/charts/base.py @@ -21,9 +21,9 @@ class Base(ChartMixin): """ def __init__( - self, - init_opts: Union[InitOpts, dict] = InitOpts(), - render_opts: Union[RenderOpts, dict] = RenderOpts() + self, + init_opts: Union[InitOpts, dict] = InitOpts(), + render_opts: Union[RenderOpts, dict] = RenderOpts(), ): _opts = init_opts if isinstance(init_opts, InitOpts): @@ -117,10 +117,10 @@ class Base(ChartMixin): self._use_theme() self._render_cache.clear() - if self.render_options.get('embed_js'): - self._render_cache['javascript'] = ( - self.load_javascript().load_javascript_contents() - ) + if self.render_options.get("embed_js"): + self._render_cache[ + "javascript" + ] = self.load_javascript().load_javascript_contents() def default(o): diff --git a/pyecharts/charts/basic_charts/calendar.py b/pyecharts/charts/basic_charts/calendar.py index 3b850e04..63a069e0 100644 --- a/pyecharts/charts/basic_charts/calendar.py +++ b/pyecharts/charts/basic_charts/calendar.py @@ -14,9 +14,9 @@ class Calendar(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.options.update(calendar=opts.CalendarOpts().opts) diff --git a/pyecharts/charts/basic_charts/geo.py b/pyecharts/charts/basic_charts/geo.py index 25a71343..f1bda889 100644 --- a/pyecharts/charts/basic_charts/geo.py +++ b/pyecharts/charts/basic_charts/geo.py @@ -10,9 +10,9 @@ from ...globals import ChartType class GeoChartBase(Chart): def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.set_global_opts() diff --git a/pyecharts/charts/basic_charts/heatmap.py b/pyecharts/charts/basic_charts/heatmap.py index 6c987ec5..af0f7906 100644 --- a/pyecharts/charts/basic_charts/heatmap.py +++ b/pyecharts/charts/basic_charts/heatmap.py @@ -14,9 +14,9 @@ class HeatMap(RectChart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.set_global_opts(visualmap_opts=opts.VisualMapOpts(orient="horizontal")) diff --git a/pyecharts/charts/basic_charts/kline.py b/pyecharts/charts/basic_charts/kline.py index 161531e3..880d7cfb 100644 --- a/pyecharts/charts/basic_charts/kline.py +++ b/pyecharts/charts/basic_charts/kline.py @@ -15,9 +15,9 @@ class Kline(RectChart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.set_global_opts( diff --git a/pyecharts/charts/basic_charts/liquid.py b/pyecharts/charts/basic_charts/liquid.py index ab06440b..8713631f 100644 --- a/pyecharts/charts/basic_charts/liquid.py +++ b/pyecharts/charts/basic_charts/liquid.py @@ -12,9 +12,9 @@ class Liquid(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.js_dependencies.add("echarts-liquidfill") diff --git a/pyecharts/charts/basic_charts/parallel.py b/pyecharts/charts/basic_charts/parallel.py index 952a55e5..f72127d6 100644 --- a/pyecharts/charts/basic_charts/parallel.py +++ b/pyecharts/charts/basic_charts/parallel.py @@ -13,9 +13,9 @@ class Parallel(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.options.update(parallel=opts.ParallelOpts().opts) diff --git a/pyecharts/charts/basic_charts/polar.py b/pyecharts/charts/basic_charts/polar.py index 9bfd223c..5e438795 100644 --- a/pyecharts/charts/basic_charts/polar.py +++ b/pyecharts/charts/basic_charts/polar.py @@ -13,9 +13,9 @@ class Polar(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.add_schema() @@ -49,9 +49,7 @@ class Polar(Chart): itemstyle_opts: types.ItemStyle = None, ): self._append_legend(series_name) - self.options.update(polar={ - "center": center if center else ["50%", "50%"] - }) + self.options.update(polar={"center": center if center else ["50%", "50%"]}) if type_ in (ChartType.SCATTER, ChartType.LINE, ChartType.BAR): self.options.get("series").append( diff --git a/pyecharts/charts/basic_charts/radar.py b/pyecharts/charts/basic_charts/radar.py index 49929b12..efb83728 100644 --- a/pyecharts/charts/basic_charts/radar.py +++ b/pyecharts/charts/basic_charts/radar.py @@ -26,7 +26,6 @@ class Radar(Chart): angleaxis_opts: types.AngleAxis = None, polar_opts: types.Polar = None, ): - self.options.update( radiusAxis=radiusaxis_opts, angleAxis=angleaxis_opts, polar=polar_opts ) diff --git a/pyecharts/charts/basic_charts/sankey.py b/pyecharts/charts/basic_charts/sankey.py index fa77da89..f46b6d19 100644 --- a/pyecharts/charts/basic_charts/sankey.py +++ b/pyecharts/charts/basic_charts/sankey.py @@ -29,7 +29,7 @@ class Sankey(Chart): layout_iterations: types.Numeric = 32, orient: str = "horizontal", is_draggable: bool = True, - focus_node_mode: str = 'none', + focus_node_mode: str = "none", levels: types.SankeyLevel = None, label_opts: types.Label = opts.LabelOpts(), linestyle_opt: types.LineStyle = opts.LineStyleOpts(), diff --git a/pyecharts/charts/basic_charts/wordcloud.py b/pyecharts/charts/basic_charts/wordcloud.py index 16e3cd38..60dcd94d 100644 --- a/pyecharts/charts/basic_charts/wordcloud.py +++ b/pyecharts/charts/basic_charts/wordcloud.py @@ -32,9 +32,9 @@ class WordCloud(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.js_dependencies.add("echarts-wordcloud") @@ -93,9 +93,7 @@ class WordCloud(Chart): ): data = [] for n, v in data_pair: - data.append( - {"name": n, "value": v, "textStyle": {"color": gen_color()}} - ) + data.append({"name": n, "value": v, "textStyle": {"color": gen_color()}}) word_size_range = word_size_range or (12, 60) diff --git a/pyecharts/charts/chart.py b/pyecharts/charts/chart.py index 7d39f77b..13cb2d33 100644 --- a/pyecharts/charts/chart.py +++ b/pyecharts/charts/chart.py @@ -7,9 +7,9 @@ from ..types import Optional, Sequence class Chart(Base): def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): if isinstance(init_opts, dict): temp_opts = opts.InitOpts() @@ -18,8 +18,7 @@ class Chart(Base): super().__init__(init_opts=init_opts, render_opts=render_opts) # Change to Echarts V5 default color list self.colors = ( - "#5470c6 #91cc75 #fac858 #ee6666 #73c0de #3ba272 #fc8452 #9a60b4 " - "#ea7ccc" + "#5470c6 #91cc75 #fac858 #ee6666 #73c0de #3ba272 #fc8452 #9a60b4 " "#ea7ccc" ).split() self.default_color_n = len(self.colors) if init_opts.opts.get("theme") == ThemeType.WHITE: @@ -34,7 +33,7 @@ class Chart(Base): def set_dark_mode( self, dark_mode_colors: Optional[Sequence[str]] = None, - dark_mode_bg_color: str = "#100C2A" + dark_mode_bg_color: str = "#100C2A", ): # [Hard Code Here] The Echarts default Dark Mode Configurations if dark_mode_colors is None: @@ -193,24 +192,26 @@ class Chart(Base): ) else: self.options.update( - dataset=[{ - "source": source, - "dimensions": dimensions, - "sourceHeader": source_header, - "transform": transform, - "fromDatasetIndex": from_dataset_index, - "fromDatasetId": from_dataset_id, - "fromTransformResult": from_transform_result, - }] + dataset=[ + { + "source": source, + "dimensions": dimensions, + "sourceHeader": source_header, + "transform": transform, + "fromDatasetIndex": from_dataset_index, + "fromDatasetId": from_dataset_id, + "fromTransformResult": from_transform_result, + } + ] ) return self class RectChart(Chart): def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.options.update(xAxis=[opts.AxisOpts().opts], yAxis=[opts.AxisOpts().opts]) @@ -252,7 +253,7 @@ class RectChart(Chart): ) self.options.get("series").extend(chart.options.get("series")) # to merge colors of chart - for c in chart.colors[:len(chart.colors) - self.default_color_n]: + for c in chart.colors[: len(chart.colors) - self.default_color_n]: self.colors.insert(len(self.colors) - self.default_color_n, c) return self @@ -263,9 +264,9 @@ class Chart3D(Chart): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): init_opts.renderer = RenderType.CANVAS super().__init__(init_opts, render_opts) @@ -376,7 +377,7 @@ class ThreeAxisChart(Chart3D): "lineStyle": wire_frame_line_style_opts, }, "equation": equation, - "parametricEquation": parametric_equation + "parametricEquation": parametric_equation, } ) else: diff --git a/pyecharts/charts/composite_charts/grid.py b/pyecharts/charts/composite_charts/grid.py index 36c7f330..a7e7d9c4 100644 --- a/pyecharts/charts/composite_charts/grid.py +++ b/pyecharts/charts/composite_charts/grid.py @@ -15,9 +15,9 @@ class Grid(Base): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.options: types.Optional[dict] = None diff --git a/pyecharts/charts/composite_charts/timeline.py b/pyecharts/charts/composite_charts/timeline.py index a642abca..f9aa2e6d 100644 --- a/pyecharts/charts/composite_charts/timeline.py +++ b/pyecharts/charts/composite_charts/timeline.py @@ -9,9 +9,9 @@ class Timeline(Base): """ def __init__( - self, - init_opts: types.Init = opts.InitOpts(), - render_opts: types.RenderInit = opts.RenderOpts() + self, + init_opts: types.Init = opts.InitOpts(), + render_opts: types.RenderInit = opts.RenderOpts(), ): super().__init__(init_opts=init_opts, render_opts=render_opts) self.options = {"baseOption": {"series": [], "timeline": {}}, "options": []} @@ -78,7 +78,7 @@ class Timeline(Base): "lineStyle": progress_linestyle_opts, "itemStyle": progress_itemstyle_opts, "label": progress_label_opts, - } + }, } ) return self diff --git a/pyecharts/charts/three_axis_charts/bar3D.py b/pyecharts/charts/three_axis_charts/bar3D.py index a80c937d..8958a8a9 100644 --- a/pyecharts/charts/three_axis_charts/bar3D.py +++ b/pyecharts/charts/three_axis_charts/bar3D.py @@ -10,9 +10,9 @@ class Bar3D(ThreeAxisChart): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.BAR3D diff --git a/pyecharts/charts/three_axis_charts/graph_gl.py b/pyecharts/charts/three_axis_charts/graph_gl.py index 4ef65559..f2a88293 100644 --- a/pyecharts/charts/three_axis_charts/graph_gl.py +++ b/pyecharts/charts/three_axis_charts/graph_gl.py @@ -12,9 +12,9 @@ class GraphGL(Chart3D): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.GRAPHGL diff --git a/pyecharts/charts/three_axis_charts/line3D.py b/pyecharts/charts/three_axis_charts/line3D.py index 8bb16075..67d2230b 100644 --- a/pyecharts/charts/three_axis_charts/line3D.py +++ b/pyecharts/charts/three_axis_charts/line3D.py @@ -10,9 +10,9 @@ class Line3D(ThreeAxisChart): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.LINE3D diff --git a/pyecharts/charts/three_axis_charts/lines3D.py b/pyecharts/charts/three_axis_charts/lines3D.py index e659ecb6..e0948b45 100644 --- a/pyecharts/charts/three_axis_charts/lines3D.py +++ b/pyecharts/charts/three_axis_charts/lines3D.py @@ -11,9 +11,9 @@ class Lines3D(Chart3D): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.LINES3D diff --git a/pyecharts/charts/three_axis_charts/map3D.py b/pyecharts/charts/three_axis_charts/map3D.py index 91bf0eea..4a608629 100644 --- a/pyecharts/charts/three_axis_charts/map3D.py +++ b/pyecharts/charts/three_axis_charts/map3D.py @@ -11,9 +11,9 @@ class Map3D(Chart3D): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.MAP3D diff --git a/pyecharts/charts/three_axis_charts/map_globe.py b/pyecharts/charts/three_axis_charts/map_globe.py index 6ee0f89c..868be02b 100644 --- a/pyecharts/charts/three_axis_charts/map_globe.py +++ b/pyecharts/charts/three_axis_charts/map_globe.py @@ -18,9 +18,9 @@ class MapGlobe(Chart3D, MapMixin): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) diff --git a/pyecharts/charts/three_axis_charts/scatter3D.py b/pyecharts/charts/three_axis_charts/scatter3D.py index e6e6560c..0b43dd38 100644 --- a/pyecharts/charts/three_axis_charts/scatter3D.py +++ b/pyecharts/charts/three_axis_charts/scatter3D.py @@ -10,9 +10,9 @@ class Scatter3D(ThreeAxisChart): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.SCATTER3D diff --git a/pyecharts/charts/three_axis_charts/surface3D.py b/pyecharts/charts/three_axis_charts/surface3D.py index 62963be8..9727d89b 100644 --- a/pyecharts/charts/three_axis_charts/surface3D.py +++ b/pyecharts/charts/three_axis_charts/surface3D.py @@ -11,9 +11,9 @@ class Surface3D(ThreeAxisChart): """ def __init__( - self, - init_opts: types.Init = InitOpts(), - render_opts: types.RenderInit = RenderOpts() + self, + init_opts: types.Init = InitOpts(), + render_opts: types.RenderInit = RenderOpts(), ): super().__init__(init_opts, render_opts) self._3d_chart_type = ChartType.SURFACE diff --git a/pyecharts/options/global_options.py b/pyecharts/options/global_options.py index 9a165325..634785ce 100644 --- a/pyecharts/options/global_options.py +++ b/pyecharts/options/global_options.py @@ -86,7 +86,7 @@ class AriaLabelOpts(BasicOpts): "separator": { "middle": series_multiple_separator_middle, "end": series_multiple_separator_end, - } + }, }, }, "data": { @@ -98,8 +98,8 @@ class AriaLabelOpts(BasicOpts): "separator": { "middle": data_separator_middle, "end": data_separator_end, - } - } + }, + }, } @@ -131,7 +131,7 @@ class AriaDecalOpts(BasicOpts): "rotation": decals_rotation, "maxTileWidth": decals_max_tile_width, "maxTileHeight": decals_max_tile_height, - } + }, } @@ -163,7 +163,7 @@ class InitOpts(BasicOpts): is_fill_bg_color: bool = False, js_host: str = "", animation_opts: Union[AnimationOpts, dict] = AnimationOpts(), - aria_opts: Union[AriaOpts, dict] = AriaOpts() + aria_opts: Union[AriaOpts, dict] = AriaOpts(), ): self.opts: dict = { "width": width, diff --git a/pyecharts/render/display.py b/pyecharts/render/display.py index 1285acf2..78c93e2a 100644 --- a/pyecharts/render/display.py +++ b/pyecharts/render/display.py @@ -75,11 +75,11 @@ class Javascript: resp: Optional[http.client.HTTPResponse] = None try: conn = http.client.HTTPSConnection(host, port) - conn.request('GET', path) + conn.request("GET", path) resp = conn.getresponse() if resp.status != 200: - raise RuntimeError('Cannot load JavaScript lib: %s' % lib) - self.javascript_contents[lib] = resp.read().decode('utf-8') + raise RuntimeError("Cannot load JavaScript lib: %s" % lib) + self.javascript_contents[lib] = resp.read().decode("utf-8") finally: if resp is not None: resp.close() diff --git a/pyecharts/render/engine.py b/pyecharts/render/engine.py index 481ba401..5edcb79d 100644 --- a/pyecharts/render/engine.py +++ b/pyecharts/render/engine.py @@ -1,4 +1,5 @@ import os + try: from collections.abc import Iterable except ImportError: diff --git a/test.py b/test.py index cd5e64cf..967afe58 100644 --- a/test.py +++ b/test.py @@ -4,8 +4,10 @@ import os # os.system("nosetests --with-coverage --cover-package pyecharts --cover-package .") # current nose -os.system("nose2 --with-coverage --coverage pyecharts " - "--coverage-config .coveragerc -s test") +os.system( + "nose2 --with-coverage --coverage pyecharts " + "--coverage-config .coveragerc -s test" +) # pytest os.system("pytest -cov-config=.coveragerc --cov=./ test/") diff --git a/test/__init__.py b/test/__init__.py index 48a10c60..a342aa3c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -2,7 +2,7 @@ import sys class ConsoleOutputRedirect: - """ Wrapper to redirect stdout or stderr """ + """Wrapper to redirect stdout or stderr""" def __init__(self, fp): self.fp = fp diff --git a/test/test_base.py b/test/test_base.py index 73e5822c..a0488d76 100644 --- a/test/test_base.py +++ b/test/test_base.py @@ -55,22 +55,24 @@ def test_render_embed_js(_): c = Base(render_opts=RenderOpts(embed_js=True)) # Embedded JavaScript content = c.render_embed() - assert_not_in(CurrentConfig.ONLINE_HOST, content, 'Embedding JavaScript fails') + assert_not_in(CurrentConfig.ONLINE_HOST, content, "Embedding JavaScript fails") # No embedded JavaScript c.render_options.update(embed_js=False) content = c.render_embed() - assert_in(CurrentConfig.ONLINE_HOST, content, 'Embedded JavaScript cannot be closed') + assert_in( + CurrentConfig.ONLINE_HOST, content, "Embedded JavaScript cannot be closed" + ) def test_base_render_options(): c0 = Base(render_opts=RenderOpts(embed_js=True)) - assert_equal(c0.render_options.get('embed_js'), True) + assert_equal(c0.render_options.get("embed_js"), True) def test_base_iso_format(): mock_time_str = "2022-04-14 14:42:00" mock_time = datetime.strptime(mock_time_str, "%Y-%m-%d %H:%M:%S") - assert (default(mock_time) == "2022-04-14T14:42:00") + assert default(mock_time) == "2022-04-14T14:42:00" def test_base_animation_option(): diff --git a/test/test_calendar.py b/test/test_calendar.py index 6a9a2a99..d8b6b241 100644 --- a/test/test_calendar.py +++ b/test/test_calendar.py @@ -47,26 +47,23 @@ def test_calendar_setting(fake_writer): for i in range((end - begin).days + 1) ] - c = ( - Calendar() - .add( - "", - data, - calendar_opts=opts.CalendarOpts( - range_="2017", - cell_size=15, - daylabel_opts=opts.CalendarDayLabelOpts(name_map="cn"), - monthlabel_opts=opts.CalendarMonthLabelOpts(name_map="cn"), - ), - visualmap_opts=opts.VisualMapOpts( - max_=20000, - min_=500, - orient="horizontal", - is_piecewise=True, - pos_top="230px", - pos_left="100px", - ) - ) + c = Calendar().add( + "", + data, + calendar_opts=opts.CalendarOpts( + range_="2017", + cell_size=15, + daylabel_opts=opts.CalendarDayLabelOpts(name_map="cn"), + monthlabel_opts=opts.CalendarMonthLabelOpts(name_map="cn"), + ), + visualmap_opts=opts.VisualMapOpts( + max_=20000, + min_=500, + orient="horizontal", + is_piecewise=True, + pos_top="230px", + pos_left="100px", + ), ) c.render() _, content = fake_writer.call_args[0] diff --git a/test/test_chart.py b/test/test_chart.py index 56c517c0..1c4764ba 100644 --- a/test/test_chart.py +++ b/test/test_chart.py @@ -247,7 +247,7 @@ def test_chart_extend_axis(fake_writer): xaxis=opts.AxisOpts(), yaxis=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value} °C"), interval=5 - ) + ), ) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts( diff --git a/test/test_custom.py b/test/test_custom.py index fd8fb8c2..bc82bdec 100644 --- a/test/test_custom.py +++ b/test/test_custom.py @@ -9,11 +9,10 @@ from pyecharts.commons.utils import JsCode @patch("pyecharts.render.engine.write_utf8_html_file") def test_custom_base(fake_writer): - c = ( - Custom() - .add( - series_name="", - render_item=JsCode(""" + c = Custom().add( + series_name="", + render_item=JsCode( + """ function (params, api) { var categoryIndex = api.value(0); var start = api.coord([api.value(1), categoryIndex]); @@ -36,9 +35,9 @@ def test_custom_base(fake_writer): style: api.style() }; } - """), - data=None, - ) + """ + ), + data=None, ) c.render() _, content = fake_writer.call_args[0] diff --git a/test/test_datasets.py b/test/test_datasets.py index d232b2a9..f23f1288 100644 --- a/test/test_datasets.py +++ b/test/test_datasets.py @@ -28,7 +28,7 @@ def test_register_url(fake): { "安庆": file_name, "English Name": file_name, - } + }, ) fake_registry_1 = os.path.join(current_path, "fixtures", "registry_1.json") @@ -40,7 +40,7 @@ def test_register_url(fake): { "安庆": file_name, "English Name": file_name, - } + }, ) diff --git a/test/test_exception.py b/test/test_exception.py index e5278483..695e9f96 100644 --- a/test/test_exception.py +++ b/test/test_exception.py @@ -19,7 +19,7 @@ def test_geo_catch_nonexistent_coord_exception(): ) except NonexistentCoordinatesException as err: assert_equal(type(err), NonexistentCoordinatesException) - assert err.__str__() != '' + assert err.__str__() != "" def test_geo_ignore_nonexistent_coord_exception(): diff --git a/test/test_faker.py b/test/test_faker.py index e83d1099..04664801 100644 --- a/test/test_faker.py +++ b/test/test_faker.py @@ -15,7 +15,6 @@ def test_img_path(): def test_collector(): - def _add(x, y): return x + y diff --git a/test/test_geo.py b/test/test_geo.py index b9564ca8..4debd8d1 100644 --- a/test/test_geo.py +++ b/test/test_geo.py @@ -178,616 +178,163 @@ def test_geo_add_geo_json(): "geometry": { "coordinates": [ [ - [ - 118.57812, - 26.557402 - ], - [ - 118.590394, - 26.553081 - ], - [ - 118.617087, - 26.553059 - ], - [ - 118.616111, - 26.527755 - ], - [ - 118.604148, - 26.504904 - ], - [ - 118.608376, - 26.497294 - ], - [ - 118.59623, - 26.478385 - ], - [ - 118.578807, - 26.473754 - ], - [ - 118.56458, - 26.465373 - ], - [ - 118.554474, - 26.445927 - ], - [ - 118.566533, - 26.432851 - ], - [ - 118.54632, - 26.417928 - ], - [ - 118.548079, - 26.396854 - ], - [ - 118.560868, - 26.378456 - ], - [ - 118.566104, - 26.358824 - ], - [ - 118.589836, - 26.373463 - ], - [ - 118.590222, - 26.359802 - ], - [ - 118.595801, - 26.347859 - ], - [ - 118.60369, - 26.350515 - ], - [ - 118.621191, - 26.361783 - ], - [ - 118.631475, - 26.354788 - ], - [ - 118.656162, - 26.340797 - ], - [ - 118.662964, - 26.322656 - ], - [ - 118.653222, - 26.313452 - ], - [ - 118.661204, - 26.296272 - ], - [ - 118.664809, - 26.270524 - ], - [ - 118.678076, - 26.279442 - ], - [ - 118.68585, - 26.28836 - ], - [ - 118.697277, - 26.287725 - ], - [ - 118.693599, - 26.305557 - ], - [ - 118.699533, - 26.311078 - ], - [ - 118.724644, - 26.337465 - ], - [ - 118.75152, - 26.330542 - ], - [ - 118.76682, - 26.327157 - ], - [ - 118.775794, - 26.325234 - ], - [ - 118.797129, - 26.340542 - ], - [ - 118.800059, - 26.357136 - ], - [ - 118.785137, - 26.365115 - ], - [ - 118.771085, - 26.385377 - ], - [ - 118.750534, - 26.390836 - ], - [ - 118.761617, - 26.420202 - ], - [ - 118.745161, - 26.427236 - ], - [ - 118.732826, - 26.437957 - ], - [ - 118.734248, - 26.45448 - ], - [ - 118.737767, - 26.472405 - ], - [ - 118.748152, - 26.481723 - ], - [ - 118.754353, - 26.487893 - ], - [ - 118.748195, - 26.494063 - ], - [ - 118.748238, - 26.506403 - ], - [ - 118.762057, - 26.508959 - ], - [ - 118.780881, - 26.504741 - ], - [ - 118.784598, - 26.491919 - ], - [ - 118.798615, - 26.484013 - ], - [ - 118.805766, - 26.474876 - ], - [ - 118.794544, - 26.459227 - ], - [ - 118.809178, - 26.445137 - ], - [ - 118.805487, - 26.430479 - ], - [ - 118.822825, - 26.420838 - ], - [ - 118.85278, - 26.438461 - ], - [ - 118.878615, - 26.469605 - ], - [ - 118.898227, - 26.473649 - ], - [ - 118.91784, - 26.472777 - ], - [ - 118.949511, - 26.464885 - ], - [ - 118.951619, - 26.487056 - ], - [ - 118.943747, - 26.493838 - ], - [ - 118.942741, - 26.507994 - ], - [ - 118.962064, - 26.530816 - ], - [ - 118.997866, - 26.528448 - ], - [ - 119.000968, - 26.556946 - ], - [ - 119.009563, - 26.560258 - ], - [ - 119.015767, - 26.581621 - ], - [ - 119.032957, - 26.594999 - ], - [ - 119.062507, - 26.602235 - ], - [ - 119.075945, - 26.587083 - ], - [ - 119.06329, - 26.569473 - ], - [ - 119.076433, - 26.569869 - ], - [ - 119.092152, - 26.562702 - ], - [ - 119.101005, - 26.572732 - ], - [ - 119.103604, - 26.555941 - ], - [ - 119.119788, - 26.539555 - ], - [ - 119.132, - 26.538732 - ], - [ - 119.144213, - 26.536681 - ], - [ - 119.171383, - 26.548551 - ], - [ - 119.194922, - 26.568383 - ], - [ - 119.212185, - 26.547589 - ], - [ - 119.218757, - 26.53412 - ], - [ - 119.229448, - 26.526792 - ], - [ - 119.251174, - 26.53241 - ], - [ - 119.253859, - 26.546561 - ], - [ - 119.272336, - 26.541055 - ], - [ - 119.281139, - 26.534343 - ], - [ - 119.287711, - 26.577995 - ], - [ - 119.301835, - 26.593391 - ], - [ - 119.329006, - 26.578699 - ], - [ - 119.354338, - 26.599587 - ], - [ - 119.363191, - 26.603281 - ], - [ - 119.376544, - 26.604515 - ], - [ - 119.381656, - 26.62171 - ], - [ - 119.397376, - 26.627859 - ], - [ - 119.387272, - 26.641423 - ], - [ - 119.375795, - 26.639028 - ], - [ - 119.358824, - 26.632951 - ], - [ - 119.351467, - 26.648969 - ], - [ - 119.326158, - 26.676212 - ], - [ - 119.261119, - 26.690807 - ], - [ - 119.241593, - 26.742684 - ], - [ - 119.226535, - 26.728854 - ], - [ - 119.204611, - 26.727288 - ], - [ - 119.182686, - 26.729403 - ], - [ - 119.167628, - 26.711891 - ], - [ - 119.146452, - 26.731884 - ], - [ - 119.115663, - 26.73961 - ], - [ - 119.047905, - 26.728693 - ], - [ - 119.045955, - 26.74669 - ], - [ - 119.054992, - 26.764685 - ], - [ - 119.051092, - 26.776147 - ], - [ - 119.042385, - 26.776575 - ], - [ - 119.033679, - 26.770872 - ], - [ - 119.012146, - 26.761305 - ], - [ - 118.982497, - 26.773075 - ], - [ - 118.945981, - 26.77013 - ], - [ - 118.926007, - 26.749652 - ], - [ - 118.882686, - 26.738982 - ], - [ - 118.887478, - 26.757469 - ], - [ - 118.903255, - 26.76737 - ], - [ - 118.923824, - 26.795751 - ], - [ - 118.890803, - 26.813278 - ], - [ - 118.843328, - 26.798569 - ], - [ - 118.827143, - 26.786924 - ], - [ - 118.795852, - 26.783859 - ], - [ - 118.771428, - 26.805618 - ], - [ - 118.741511, - 26.818793 - ], - [ - 118.728195, - 26.830895 - ], - [ - 118.722432, - 26.851573 - ], - [ - 118.739746, - 26.856167 - ], - [ - 118.696095, - 26.869031 - ], - [ - 118.664633, - 26.86214 - ], - [ - 118.63317, - 26.855248 - ], - [ - 118.620069, - 26.839818 - ], - [ - 118.635807, - 26.832963 - ], - [ - 118.638444, - 26.810674 - ], - [ - 118.625974, - 26.788073 - ], - [ - 118.623117, - 26.769147 - ], - [ - 118.600382, - 26.7093 - ], - [ - 118.582339, - 26.703842 - ], - [ - 118.569788, - 26.680592 - ], - [ - 118.57902, - 26.673354 - ], - [ - 118.594415, - 26.673546 - ], - [ - 118.594991, - 26.656748 - ], - [ - 118.587905, - 26.631739 - ], - [ - 118.57812, - 26.557402 - ] + [118.57812, 26.557402], + [118.590394, 26.553081], + [118.617087, 26.553059], + [118.616111, 26.527755], + [118.604148, 26.504904], + [118.608376, 26.497294], + [118.59623, 26.478385], + [118.578807, 26.473754], + [118.56458, 26.465373], + [118.554474, 26.445927], + [118.566533, 26.432851], + [118.54632, 26.417928], + [118.548079, 26.396854], + [118.560868, 26.378456], + [118.566104, 26.358824], + [118.589836, 26.373463], + [118.590222, 26.359802], + [118.595801, 26.347859], + [118.60369, 26.350515], + [118.621191, 26.361783], + [118.631475, 26.354788], + [118.656162, 26.340797], + [118.662964, 26.322656], + [118.653222, 26.313452], + [118.661204, 26.296272], + [118.664809, 26.270524], + [118.678076, 26.279442], + [118.68585, 26.28836], + [118.697277, 26.287725], + [118.693599, 26.305557], + [118.699533, 26.311078], + [118.724644, 26.337465], + [118.75152, 26.330542], + [118.76682, 26.327157], + [118.775794, 26.325234], + [118.797129, 26.340542], + [118.800059, 26.357136], + [118.785137, 26.365115], + [118.771085, 26.385377], + [118.750534, 26.390836], + [118.761617, 26.420202], + [118.745161, 26.427236], + [118.732826, 26.437957], + [118.734248, 26.45448], + [118.737767, 26.472405], + [118.748152, 26.481723], + [118.754353, 26.487893], + [118.748195, 26.494063], + [118.748238, 26.506403], + [118.762057, 26.508959], + [118.780881, 26.504741], + [118.784598, 26.491919], + [118.798615, 26.484013], + [118.805766, 26.474876], + [118.794544, 26.459227], + [118.809178, 26.445137], + [118.805487, 26.430479], + [118.822825, 26.420838], + [118.85278, 26.438461], + [118.878615, 26.469605], + [118.898227, 26.473649], + [118.91784, 26.472777], + [118.949511, 26.464885], + [118.951619, 26.487056], + [118.943747, 26.493838], + [118.942741, 26.507994], + [118.962064, 26.530816], + [118.997866, 26.528448], + [119.000968, 26.556946], + [119.009563, 26.560258], + [119.015767, 26.581621], + [119.032957, 26.594999], + [119.062507, 26.602235], + [119.075945, 26.587083], + [119.06329, 26.569473], + [119.076433, 26.569869], + [119.092152, 26.562702], + [119.101005, 26.572732], + [119.103604, 26.555941], + [119.119788, 26.539555], + [119.132, 26.538732], + [119.144213, 26.536681], + [119.171383, 26.548551], + [119.194922, 26.568383], + [119.212185, 26.547589], + [119.218757, 26.53412], + [119.229448, 26.526792], + [119.251174, 26.53241], + [119.253859, 26.546561], + [119.272336, 26.541055], + [119.281139, 26.534343], + [119.287711, 26.577995], + [119.301835, 26.593391], + [119.329006, 26.578699], + [119.354338, 26.599587], + [119.363191, 26.603281], + [119.376544, 26.604515], + [119.381656, 26.62171], + [119.397376, 26.627859], + [119.387272, 26.641423], + [119.375795, 26.639028], + [119.358824, 26.632951], + [119.351467, 26.648969], + [119.326158, 26.676212], + [119.261119, 26.690807], + [119.241593, 26.742684], + [119.226535, 26.728854], + [119.204611, 26.727288], + [119.182686, 26.729403], + [119.167628, 26.711891], + [119.146452, 26.731884], + [119.115663, 26.73961], + [119.047905, 26.728693], + [119.045955, 26.74669], + [119.054992, 26.764685], + [119.051092, 26.776147], + [119.042385, 26.776575], + [119.033679, 26.770872], + [119.012146, 26.761305], + [118.982497, 26.773075], + [118.945981, 26.77013], + [118.926007, 26.749652], + [118.882686, 26.738982], + [118.887478, 26.757469], + [118.903255, 26.76737], + [118.923824, 26.795751], + [118.890803, 26.813278], + [118.843328, 26.798569], + [118.827143, 26.786924], + [118.795852, 26.783859], + [118.771428, 26.805618], + [118.741511, 26.818793], + [118.728195, 26.830895], + [118.722432, 26.851573], + [118.739746, 26.856167], + [118.696095, 26.869031], + [118.664633, 26.86214], + [118.63317, 26.855248], + [118.620069, 26.839818], + [118.635807, 26.832963], + [118.638444, 26.810674], + [118.625974, 26.788073], + [118.623117, 26.769147], + [118.600382, 26.7093], + [118.582339, 26.703842], + [118.569788, 26.680592], + [118.57902, 26.673354], + [118.594415, 26.673546], + [118.594991, 26.656748], + [118.587905, 26.631739], + [118.57812, 26.557402], ] ], - "type": "Polygon" - } + "type": "Polygon", + }, } - ] + ], } c = Geo() diff --git a/test/test_global_options.py b/test/test_global_options.py index 7b8f8622..794996c6 100644 --- a/test/test_global_options.py +++ b/test/test_global_options.py @@ -66,7 +66,7 @@ def test_aria_label_options_remove_none(): "separator": { "middle": ";", "end": "。", - } + }, }, }, "data": { @@ -77,8 +77,8 @@ def test_aria_label_options_remove_none(): "withoutName": "{value}", "separator": { "middle": ",", - } - } + }, + }, } assert_equal(expected, remove_key_with_none_value(option.opts)) @@ -97,7 +97,7 @@ def test_aria_decal_options_remove_none(): "rotation": 0, "maxTileWidth": 512, "maxTileHeight": 512, - } + }, } assert_equal(expected, remove_key_with_none_value(option.opts)) @@ -347,8 +347,5 @@ def test_radius_axis_options_remove_none(): def test_dataset_transform_options_remove_none(): option = DatasetTransformOpts() - expected = { - "type": "filter", - "print": False - } + expected = {"type": "filter", "print": False} assert_equal(expected, remove_key_with_none_value(option.opts)) diff --git a/test/test_graph_gl.py b/test/test_graph_gl.py index f9d08579..1c303981 100644 --- a/test/test_graph_gl.py +++ b/test/test_graph_gl.py @@ -14,27 +14,33 @@ def test_graph_gl_base(fake_writer): nodes = [] for i in range(50): for j in range(50): - nodes.append(opts.GraphGLNode( - x=random.random() * 958, - y=random.random() * 777, - value=1, - )) + nodes.append( + opts.GraphGLNode( + x=random.random() * 958, + y=random.random() * 777, + value=1, + ) + ) links = [] for i in range(50): for j in range(50): if i < 50 - 1: - links.append(opts.GraphGLLink( - source=i + j * 50, - target=i + 1 + j * 50, - value=1, - )) + links.append( + opts.GraphGLLink( + source=i + j * 50, + target=i + 1 + j * 50, + value=1, + ) + ) if j < 50 - 1: - links.append(opts.GraphGLLink( - source=i + j * 50, - target=i + (j + 1) * 50, - value=1, - )) + links.append( + opts.GraphGLLink( + source=i + j * 50, + target=i + (j + 1) * 50, + value=1, + ) + ) c = ( GraphGL(init_opts=opts.InitOpts()) @@ -47,7 +53,7 @@ def test_graph_gl_base(fake_writer): force_atlas2_opts=opts.GraphGLForceAtlas2Opts( steps=5, edge_weight_influence=4, - ) + ), ) .set_dark_mode() ) diff --git a/test/test_graphic.py b/test/test_graphic.py index 06d51c48..39f9d2a9 100644 --- a/test/test_graphic.py +++ b/test/test_graphic.py @@ -23,30 +23,28 @@ def test_graphic_group(): def test_graphic_image(): image = opts.GraphicImage( - graphic_item={"item": 1}, - graphic_imagestyle_opts={"opts": 1} + graphic_item={"item": 1}, graphic_imagestyle_opts={"opts": 1} ) expected = { "type": "image", "item": 1, "style": { "opts": 1, - } + }, } assert_equal(expected, remove_key_with_none_value(image.opts)) def test_graphic_text(): text = opts.GraphicText( - graphic_item={"item": 1}, - graphic_textstyle_opts={"opts": 1} + graphic_item={"item": 1}, graphic_textstyle_opts={"opts": 1} ) expected = { "type": "text", "item": 1, "style": { "opts": 1, - } + }, } assert_equal(expected, remove_key_with_none_value(text.opts)) @@ -63,6 +61,6 @@ def test_graphic_rect(): "shape": 1, "style": { "opts": 1, - } + }, } assert_equal(expected, remove_key_with_none_value(rect.opts)) diff --git a/test/test_grid.py b/test/test_grid.py index e8b4b1ac..833e929c 100644 --- a/test/test_grid.py +++ b/test/test_grid.py @@ -178,34 +178,26 @@ def test_grid_two_radar(fake_writer): ] c = ( Radar() - .add_schema(schema=schema, center=['25%', '50%']) + .add_schema(schema=schema, center=["25%", "50%"]) .add( series_name="预算分配", data=[[4300, 10000, 28000, 35000, 50000, 19000]], radar_index=0, ) - .set_global_opts( - legend_opts=opts.LegendOpts(pos_left="20%") - ) + .set_global_opts(legend_opts=opts.LegendOpts(pos_left="20%")) ) c2 = ( Radar() - .add_schema(schema=schema, center=['75%', '50%']) + .add_schema(schema=schema, center=["75%", "50%"]) .add( series_name="实际开销", data=[[5000, 14000, 28000, 31000, 42000, 21000]], radar_index=1, ) - .set_global_opts( - legend_opts=opts.LegendOpts(pos_right="20%") - ) + .set_global_opts(legend_opts=opts.LegendOpts(pos_right="20%")) ) - grid = ( - Grid() - .add(c, grid_opts=opts.GridOpts()) - .add(c2, grid_opts=opts.GridOpts()) - ) + grid = Grid().add(c, grid_opts=opts.GridOpts()).add(c2, grid_opts=opts.GridOpts()) grid.render() _, content = fake_writer.call_args[0] assert_in("radar", content) diff --git a/test/test_kline.py b/test/test_kline.py index 92bc86da..cb8f632f 100644 --- a/test/test_kline.py +++ b/test/test_kline.py @@ -41,8 +41,7 @@ def test_kline_item_base(fake_writer): x_axis = ["2017/7/{}".format(i + 1) for i in range(10)] y_axis = data kline_item = [ - opts.CandleStickItem(name=d[0], value=d[1]) - for d in list(zip(x_axis, y_axis)) + opts.CandleStickItem(name=d[0], value=d[1]) for d in list(zip(x_axis, y_axis)) ] c = ( diff --git a/test/test_lines3d.py b/test/test_lines3d.py index 93dfd9b2..7c1f804f 100644 --- a/test/test_lines3d.py +++ b/test/test_lines3d.py @@ -9,8 +9,9 @@ from pyecharts.charts import Lines3D @patch("pyecharts.render.engine.write_utf8_html_file") def test_lines3d_base(fake_writer): - test_main_url: str = \ + test_main_url: str = ( "https://cdn.jsdelivr.net/gh/apache/echarts-website@asf-site/examples" + ) data_json_url = test_main_url + "/data-gl/asset/data/flights.json" base_texture = test_main_url + "/data-gl/asset/world.topo.bathy.200401.jpg" height_texture = test_main_url + "/data-gl/asset/bathymetry_bw_composite_4k.jpg" diff --git a/test/test_map.py b/test/test_map.py index 0120ab25..9ded9924 100644 --- a/test/test_map.py +++ b/test/test_map.py @@ -63,616 +63,163 @@ def test_map_add_geo_json(): "geometry": { "coordinates": [ [ - [ - 118.57812, - 26.557402 - ], - [ - 118.590394, - 26.553081 - ], - [ - 118.617087, - 26.553059 - ], - [ - 118.616111, - 26.527755 - ], - [ - 118.604148, - 26.504904 - ], - [ - 118.608376, - 26.497294 - ], - [ - 118.59623, - 26.478385 - ], - [ - 118.578807, - 26.473754 - ], - [ - 118.56458, - 26.465373 - ], - [ - 118.554474, - 26.445927 - ], - [ - 118.566533, - 26.432851 - ], - [ - 118.54632, - 26.417928 - ], - [ - 118.548079, - 26.396854 - ], - [ - 118.560868, - 26.378456 - ], - [ - 118.566104, - 26.358824 - ], - [ - 118.589836, - 26.373463 - ], - [ - 118.590222, - 26.359802 - ], - [ - 118.595801, - 26.347859 - ], - [ - 118.60369, - 26.350515 - ], - [ - 118.621191, - 26.361783 - ], - [ - 118.631475, - 26.354788 - ], - [ - 118.656162, - 26.340797 - ], - [ - 118.662964, - 26.322656 - ], - [ - 118.653222, - 26.313452 - ], - [ - 118.661204, - 26.296272 - ], - [ - 118.664809, - 26.270524 - ], - [ - 118.678076, - 26.279442 - ], - [ - 118.68585, - 26.28836 - ], - [ - 118.697277, - 26.287725 - ], - [ - 118.693599, - 26.305557 - ], - [ - 118.699533, - 26.311078 - ], - [ - 118.724644, - 26.337465 - ], - [ - 118.75152, - 26.330542 - ], - [ - 118.76682, - 26.327157 - ], - [ - 118.775794, - 26.325234 - ], - [ - 118.797129, - 26.340542 - ], - [ - 118.800059, - 26.357136 - ], - [ - 118.785137, - 26.365115 - ], - [ - 118.771085, - 26.385377 - ], - [ - 118.750534, - 26.390836 - ], - [ - 118.761617, - 26.420202 - ], - [ - 118.745161, - 26.427236 - ], - [ - 118.732826, - 26.437957 - ], - [ - 118.734248, - 26.45448 - ], - [ - 118.737767, - 26.472405 - ], - [ - 118.748152, - 26.481723 - ], - [ - 118.754353, - 26.487893 - ], - [ - 118.748195, - 26.494063 - ], - [ - 118.748238, - 26.506403 - ], - [ - 118.762057, - 26.508959 - ], - [ - 118.780881, - 26.504741 - ], - [ - 118.784598, - 26.491919 - ], - [ - 118.798615, - 26.484013 - ], - [ - 118.805766, - 26.474876 - ], - [ - 118.794544, - 26.459227 - ], - [ - 118.809178, - 26.445137 - ], - [ - 118.805487, - 26.430479 - ], - [ - 118.822825, - 26.420838 - ], - [ - 118.85278, - 26.438461 - ], - [ - 118.878615, - 26.469605 - ], - [ - 118.898227, - 26.473649 - ], - [ - 118.91784, - 26.472777 - ], - [ - 118.949511, - 26.464885 - ], - [ - 118.951619, - 26.487056 - ], - [ - 118.943747, - 26.493838 - ], - [ - 118.942741, - 26.507994 - ], - [ - 118.962064, - 26.530816 - ], - [ - 118.997866, - 26.528448 - ], - [ - 119.000968, - 26.556946 - ], - [ - 119.009563, - 26.560258 - ], - [ - 119.015767, - 26.581621 - ], - [ - 119.032957, - 26.594999 - ], - [ - 119.062507, - 26.602235 - ], - [ - 119.075945, - 26.587083 - ], - [ - 119.06329, - 26.569473 - ], - [ - 119.076433, - 26.569869 - ], - [ - 119.092152, - 26.562702 - ], - [ - 119.101005, - 26.572732 - ], - [ - 119.103604, - 26.555941 - ], - [ - 119.119788, - 26.539555 - ], - [ - 119.132, - 26.538732 - ], - [ - 119.144213, - 26.536681 - ], - [ - 119.171383, - 26.548551 - ], - [ - 119.194922, - 26.568383 - ], - [ - 119.212185, - 26.547589 - ], - [ - 119.218757, - 26.53412 - ], - [ - 119.229448, - 26.526792 - ], - [ - 119.251174, - 26.53241 - ], - [ - 119.253859, - 26.546561 - ], - [ - 119.272336, - 26.541055 - ], - [ - 119.281139, - 26.534343 - ], - [ - 119.287711, - 26.577995 - ], - [ - 119.301835, - 26.593391 - ], - [ - 119.329006, - 26.578699 - ], - [ - 119.354338, - 26.599587 - ], - [ - 119.363191, - 26.603281 - ], - [ - 119.376544, - 26.604515 - ], - [ - 119.381656, - 26.62171 - ], - [ - 119.397376, - 26.627859 - ], - [ - 119.387272, - 26.641423 - ], - [ - 119.375795, - 26.639028 - ], - [ - 119.358824, - 26.632951 - ], - [ - 119.351467, - 26.648969 - ], - [ - 119.326158, - 26.676212 - ], - [ - 119.261119, - 26.690807 - ], - [ - 119.241593, - 26.742684 - ], - [ - 119.226535, - 26.728854 - ], - [ - 119.204611, - 26.727288 - ], - [ - 119.182686, - 26.729403 - ], - [ - 119.167628, - 26.711891 - ], - [ - 119.146452, - 26.731884 - ], - [ - 119.115663, - 26.73961 - ], - [ - 119.047905, - 26.728693 - ], - [ - 119.045955, - 26.74669 - ], - [ - 119.054992, - 26.764685 - ], - [ - 119.051092, - 26.776147 - ], - [ - 119.042385, - 26.776575 - ], - [ - 119.033679, - 26.770872 - ], - [ - 119.012146, - 26.761305 - ], - [ - 118.982497, - 26.773075 - ], - [ - 118.945981, - 26.77013 - ], - [ - 118.926007, - 26.749652 - ], - [ - 118.882686, - 26.738982 - ], - [ - 118.887478, - 26.757469 - ], - [ - 118.903255, - 26.76737 - ], - [ - 118.923824, - 26.795751 - ], - [ - 118.890803, - 26.813278 - ], - [ - 118.843328, - 26.798569 - ], - [ - 118.827143, - 26.786924 - ], - [ - 118.795852, - 26.783859 - ], - [ - 118.771428, - 26.805618 - ], - [ - 118.741511, - 26.818793 - ], - [ - 118.728195, - 26.830895 - ], - [ - 118.722432, - 26.851573 - ], - [ - 118.739746, - 26.856167 - ], - [ - 118.696095, - 26.869031 - ], - [ - 118.664633, - 26.86214 - ], - [ - 118.63317, - 26.855248 - ], - [ - 118.620069, - 26.839818 - ], - [ - 118.635807, - 26.832963 - ], - [ - 118.638444, - 26.810674 - ], - [ - 118.625974, - 26.788073 - ], - [ - 118.623117, - 26.769147 - ], - [ - 118.600382, - 26.7093 - ], - [ - 118.582339, - 26.703842 - ], - [ - 118.569788, - 26.680592 - ], - [ - 118.57902, - 26.673354 - ], - [ - 118.594415, - 26.673546 - ], - [ - 118.594991, - 26.656748 - ], - [ - 118.587905, - 26.631739 - ], - [ - 118.57812, - 26.557402 - ] + [118.57812, 26.557402], + [118.590394, 26.553081], + [118.617087, 26.553059], + [118.616111, 26.527755], + [118.604148, 26.504904], + [118.608376, 26.497294], + [118.59623, 26.478385], + [118.578807, 26.473754], + [118.56458, 26.465373], + [118.554474, 26.445927], + [118.566533, 26.432851], + [118.54632, 26.417928], + [118.548079, 26.396854], + [118.560868, 26.378456], + [118.566104, 26.358824], + [118.589836, 26.373463], + [118.590222, 26.359802], + [118.595801, 26.347859], + [118.60369, 26.350515], + [118.621191, 26.361783], + [118.631475, 26.354788], + [118.656162, 26.340797], + [118.662964, 26.322656], + [118.653222, 26.313452], + [118.661204, 26.296272], + [118.664809, 26.270524], + [118.678076, 26.279442], + [118.68585, 26.28836], + [118.697277, 26.287725], + [118.693599, 26.305557], + [118.699533, 26.311078], + [118.724644, 26.337465], + [118.75152, 26.330542], + [118.76682, 26.327157], + [118.775794, 26.325234], + [118.797129, 26.340542], + [118.800059, 26.357136], + [118.785137, 26.365115], + [118.771085, 26.385377], + [118.750534, 26.390836], + [118.761617, 26.420202], + [118.745161, 26.427236], + [118.732826, 26.437957], + [118.734248, 26.45448], + [118.737767, 26.472405], + [118.748152, 26.481723], + [118.754353, 26.487893], + [118.748195, 26.494063], + [118.748238, 26.506403], + [118.762057, 26.508959], + [118.780881, 26.504741], + [118.784598, 26.491919], + [118.798615, 26.484013], + [118.805766, 26.474876], + [118.794544, 26.459227], + [118.809178, 26.445137], + [118.805487, 26.430479], + [118.822825, 26.420838], + [118.85278, 26.438461], + [118.878615, 26.469605], + [118.898227, 26.473649], + [118.91784, 26.472777], + [118.949511, 26.464885], + [118.951619, 26.487056], + [118.943747, 26.493838], + [118.942741, 26.507994], + [118.962064, 26.530816], + [118.997866, 26.528448], + [119.000968, 26.556946], + [119.009563, 26.560258], + [119.015767, 26.581621], + [119.032957, 26.594999], + [119.062507, 26.602235], + [119.075945, 26.587083], + [119.06329, 26.569473], + [119.076433, 26.569869], + [119.092152, 26.562702], + [119.101005, 26.572732], + [119.103604, 26.555941], + [119.119788, 26.539555], + [119.132, 26.538732], + [119.144213, 26.536681], + [119.171383, 26.548551], + [119.194922, 26.568383], + [119.212185, 26.547589], + [119.218757, 26.53412], + [119.229448, 26.526792], + [119.251174, 26.53241], + [119.253859, 26.546561], + [119.272336, 26.541055], + [119.281139, 26.534343], + [119.287711, 26.577995], + [119.301835, 26.593391], + [119.329006, 26.578699], + [119.354338, 26.599587], + [119.363191, 26.603281], + [119.376544, 26.604515], + [119.381656, 26.62171], + [119.397376, 26.627859], + [119.387272, 26.641423], + [119.375795, 26.639028], + [119.358824, 26.632951], + [119.351467, 26.648969], + [119.326158, 26.676212], + [119.261119, 26.690807], + [119.241593, 26.742684], + [119.226535, 26.728854], + [119.204611, 26.727288], + [119.182686, 26.729403], + [119.167628, 26.711891], + [119.146452, 26.731884], + [119.115663, 26.73961], + [119.047905, 26.728693], + [119.045955, 26.74669], + [119.054992, 26.764685], + [119.051092, 26.776147], + [119.042385, 26.776575], + [119.033679, 26.770872], + [119.012146, 26.761305], + [118.982497, 26.773075], + [118.945981, 26.77013], + [118.926007, 26.749652], + [118.882686, 26.738982], + [118.887478, 26.757469], + [118.903255, 26.76737], + [118.923824, 26.795751], + [118.890803, 26.813278], + [118.843328, 26.798569], + [118.827143, 26.786924], + [118.795852, 26.783859], + [118.771428, 26.805618], + [118.741511, 26.818793], + [118.728195, 26.830895], + [118.722432, 26.851573], + [118.739746, 26.856167], + [118.696095, 26.869031], + [118.664633, 26.86214], + [118.63317, 26.855248], + [118.620069, 26.839818], + [118.635807, 26.832963], + [118.638444, 26.810674], + [118.625974, 26.788073], + [118.623117, 26.769147], + [118.600382, 26.7093], + [118.582339, 26.703842], + [118.569788, 26.680592], + [118.57902, 26.673354], + [118.594415, 26.673546], + [118.594991, 26.656748], + [118.587905, 26.631739], + [118.57812, 26.557402], ] ], - "type": "Polygon" - } + "type": "Polygon", + }, } - ] + ], } c = Map() diff --git a/test/test_page.py b/test/test_page.py index 3e72bc89..a2616735 100644 --- a/test/test_page.py +++ b/test/test_page.py @@ -177,9 +177,7 @@ def test_page_resize(): def test_page_resize_cfg(): page = Page() - content = page.save_resize_html( - cfg_file="test/fixtures/resize_cfg.json" - ) + content = page.save_resize_html(cfg_file="test/fixtures/resize_cfg.json") assert_not_in(".resizable()", content) assert_not_in(".draggable()", content) diff --git a/test/test_parallel.py b/test/test_parallel.py index 1bc9b1c3..bd29d383 100644 --- a/test/test_parallel.py +++ b/test/test_parallel.py @@ -72,7 +72,7 @@ def test_parallel_base_v1(fake_writer): data=["优", "良", "轻度污染", "中度污染", "重度污染", "严重污染"], ), ], - parallel_opts=opts.ParallelOpts() + parallel_opts=opts.ParallelOpts(), ) .add("parallel", data) .set_global_opts(title_opts=opts.TitleOpts(title="Parallel-Category")) diff --git a/test/test_series_options.py b/test/test_series_options.py index d53aec51..d390e5cf 100644 --- a/test/test_series_options.py +++ b/test/test_series_options.py @@ -82,22 +82,25 @@ def test_mark_line_item_remove_none(): def test_mark_area_item_remove_none(): item = MarkAreaItem() - expected = [{ - "itemStyle": None, - "label": None, - "name": None, - "type": None, - "valueDim": None, - "valueIndex": None, - "xAxis": None, - "yAxis": None, - }, { - "type": None, - "valueDim": None, - "valueIndex": None, - "xAxis": None, - "yAxis": None, - }] + expected = [ + { + "itemStyle": None, + "label": None, + "name": None, + "type": None, + "valueDim": None, + "valueIndex": None, + "xAxis": None, + "yAxis": None, + }, + { + "type": None, + "valueDim": None, + "valueIndex": None, + "xAxis": None, + "yAxis": None, + }, + ] assert_equal(expected, remove_key_with_none_value(item.opts)) diff --git a/test/test_snapshot.py b/test/test_snapshot.py index a22bd631..a7d34675 100644 --- a/test/test_snapshot.py +++ b/test/test_snapshot.py @@ -25,11 +25,11 @@ def _gen_faker_engine(content: str): def test_decode_base64(): - assert decode_base64(data="abcde12") == b'i\xb7\x1d{]' + assert decode_base64(data="abcde12") == b"i\xb7\x1d{]" def test_save_as_png(): - save_as_png(image_data=b'i\xb7\x1d{]', output_name="text_png.png") + save_as_png(image_data=b"i\xb7\x1d{]", output_name="text_png.png") os.unlink("text_png.png") diff --git a/test/test_tab.py b/test/test_tab.py index 10ee3568..4c44ef86 100644 --- a/test/test_tab.py +++ b/test/test_tab.py @@ -55,6 +55,7 @@ def test_tab_render_embed(): def test_tab_render_notebook(): from pyecharts.globals import CurrentConfig, NotebookType + CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_NOTEBOOK tab = Tab() @@ -96,8 +97,9 @@ def test_tab_attr(): def test_tab_with_chart_container(): - tab = Tab(tab_css_opts=opts.TabChartGlobalOpts( - is_enable=False, - tab_base_css={"overflow": "hidden"} - )) + tab = Tab( + tab_css_opts=opts.TabChartGlobalOpts( + is_enable=False, tab_base_css={"overflow": "hidden"} + ) + ) assert_true(isinstance(tab._charts, list)) diff --git a/test/test_utils.py b/test/test_utils.py index 2656fa68..5df998b6 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -10,10 +10,12 @@ def test_utils_produce_require_dict(): assert_equal(cfg["libraries"], ["'echarts'"]) cfg_1 = utils.produce_require_dict( - utils.OrderedSet("https://api.map.baidu.com"), "https://example.com", + utils.OrderedSet("https://api.map.baidu.com"), + "https://example.com", ) assert_equal( - cfg_1["config_items"], ["'baidu_map_api25':'https://api.map.baidu.com'"], + cfg_1["config_items"], + ["'baidu_map_api25':'https://api.map.baidu.com'"], ) assert_equal(cfg_1["libraries"], ["'baidu_map_api25'"]) @@ -24,7 +26,8 @@ def test_utils_produce_require_dict_with_extra(): "https://api.baidu.com/test.min": ["https://api.baidu.com/test.min", "css"] } cfg_0 = utils.produce_require_dict( - utils.OrderedSet("https://api.baidu.com/test.min"), "https://example.com", + utils.OrderedSet("https://api.baidu.com/test.min"), + "https://example.com", ) assert_equal(cfg_0["libraries"], ["'https://api.baidu.com/test.min'"])