Skip to content

Commit

Permalink
Hand-converted some percent formatted strings to f-strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 1, 2024
1 parent 3beb5fb commit 518bd02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion svg/charts/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def draw_data(self):

d = ' '.join(('M', origin, 'L', line_path, area_path, 'Z'))
etree.SubElement(
self.graph, 'path', {'class': 'fill{line_n}'.format(**vars()), 'd': d}
self.graph,
'path',
{'class': 'fill{line_n}'.format(**vars()), 'd': d},
)

# now draw the line itself
Expand Down
12 changes: 6 additions & 6 deletions svg/charts/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def get_single_axis_values(self, axis, dataset):
"""
Return all the values for a single axis of the data.
"""
data_index = getattr(self, '%s_data_index' % axis)
data_index = getattr(self, f'{axis}_data_index')
return [p[data_index] for p in dataset['data']]

def data_max(self, axis):
Expand All @@ -205,7 +205,7 @@ def data_max(self, axis):
self.get_single_axis_values(axis, ds) for ds in self.data
)
)
spec_max = getattr(self, 'max_%s_value' % axis)
spec_max = getattr(self, f'max_{axis}_value')
if spec_max is not None:
max_value = max(max_value, spec_max)
return max_value
Expand All @@ -216,7 +216,7 @@ def data_min(self, axis):
self.get_single_axis_values(axis, ds) for ds in self.data
)
)
spec_min = getattr(self, 'min_%s_value' % axis)
spec_min = getattr(self, f'min_{axis}_value')
if spec_min is not None:
min_value = min(min_value, spec_min)
return min_value
Expand All @@ -227,7 +227,7 @@ def data_min(self, axis):
def data_range(self, axis):
min_value = self.data_min(axis)
max_value = self.data_max(axis)
if getattr(self, 'scale_%s_integers' % axis):
if getattr(self, f'scale_{axis}_integers'):
min_value = math.floor(min_value)
max_value = math.ceil(max_value)

Expand All @@ -236,11 +236,11 @@ def data_range(self, axis):
side_pad = range / 20.0 or 10
scale_range = (max_value + side_pad) - min_value

scale_division = getattr(self, 'scale_%s_divisions' % axis) or (
scale_division = getattr(self, f'scale_{axis}_divisions') or (
scale_range / 10.0
)

if getattr(self, 'scale_%s_integers' % axis):
if getattr(self, f'scale_{axis}_integers'):
scale_division = round(scale_division) or 1

return min_value, max_value, scale_division
Expand Down

0 comments on commit 518bd02

Please sign in to comment.