Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Feb 6, 2022
1 parent b20d1d2 commit 7b91ed7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dash_charts/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""List of lists containing each possible filter string."""


def split_filter_part(filter_part): # noqa: CCR001
def split_filter_part(filter_part): # noqa: CCR001
"""Split the filter into `(name, operator, value)` components.
Based on `Backend Paging with Filtering`: https://dash.plot.ly/datatable/callbacks
Expand All @@ -45,7 +45,7 @@ def split_filter_part(filter_part): # noqa: CCR001
value_part = value_part.strip()
v0 = value_part[0]
if (v0 == value_part[-1] and v0 in ("'", '"', '`')):
value = value_part[1: -1].replace('\\' + v0, v0)
value = value_part[1: -1].replace(f'\\{v0}', v0)
else:
try:
value = float(value_part)
Expand Down
3 changes: 1 addition & 2 deletions dash_charts/utils_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ def export_table_as_csv(csv_filename, table):
"""
rows = [[*table.columns]]
for row in table:
rows.append([*row.values()])
rows.extend([*row.values()] for row in table)
write_csv(csv_filename, rows)


Expand Down
3 changes: 1 addition & 2 deletions dash_charts/utils_fig.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ def axis_range(self):

@axis_range.setter
def axis_range(self, axis_range):
errors = validate(axis_range, self._axis_range_schema)
if errors:
if errors := validate(axis_range, self._axis_range_schema):
raise RuntimeError(f'Validation of self.axis_range failed: {errors}')
# Assign new axis_range
self._axis_range = axis_range
Expand Down
7 changes: 2 additions & 5 deletions tests/examples/ex_marginal_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ def create_marg_right(self, df_raw):
"""
key = 'name'
return [
go.Violin(
return [go.Violin(
marker_color='royalblue',
name=str(name),
showlegend=False,
x=df_raw[key][df_raw[key] == name],
y=df_raw['y'][df_raw[key] == name],
)
for idx, name in enumerate(np.sort(df_raw[key].unique()))
]
) for name in np.sort(df_raw[key].unique())]

def create_layout(self):
"""Extend the standard layout.
Expand Down
19 changes: 15 additions & 4 deletions tests/examples/ex_rolling_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,23 @@ def return_layout(self) -> dict:
'maxWidth': '1000px',
'marginRight': 'auto',
'marginLeft': 'auto',
}, children=[
},
children=[
html.H4(children=self.name),
min_graph(id=self._il[self.id_chart], figure=self.chart_main.create_figure(self.data_raw)),
min_graph(
id=self._il[self.id_chart],
figure=self.chart_main.create_figure(self.data_raw),
),
dcc.RangeSlider(
id=self._il[self.id_slider], min=0, max=slider_max, step=step / 5, value=[150, 825],
marks={str(idx * step): str(idx * step) for idx in range(int(slider_max / step))},
id=self._il[self.id_slider],
min=0,
max=slider_max,
step=step / 5,
value=[150, 825],
marks={
str(idx * step): str(idx * step)
for idx in range(slider_max // step)
},
),
],
)
Expand Down

0 comments on commit 7b91ed7

Please sign in to comment.