Skip to content

Commit 033111f

Browse files
committed
rely on re to escape trailing separator
1 parent 218fa24 commit 033111f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/matplotlib/ticker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
import six
175175

176176
import itertools
177+
import re
177178
import locale
178179
import math
179180
import numpy as np
@@ -1240,8 +1241,7 @@ def __init__(self, unit="", places=None, sep=" "):
12401241
def __call__(self, x, pos=None):
12411242
s = "%s%s" % (self.format_eng(x), self.unit)
12421243
# Remove the trailing separator when there is neither prefix nor unit
1243-
if len(self.sep) > 0 and s.endswith(self.sep):
1244-
s = s[:-len(self.sep)]
1244+
s = re.sub(re.escape(self.sep) + "$", "", s)
12451245
return self.fix_minus(s)
12461246

12471247
def format_eng(self, num):

0 commit comments

Comments
 (0)