Skip to content
Snippets Groups Projects

Fix _repr_svg_ and refactor sorting

Merged Oscar Gustafsson requested to merge sortrefactor into master
1 file
+ 8
3
Compare changes
  • Side-by-side
  • Inline
+ 8
3
@@ -24,8 +24,13 @@ _T = TypeVar('_T')
@@ -24,8 +24,13 @@ _T = TypeVar('_T')
def _sorted_nicely(to_be_sorted: Iterable[_T]) -> List[_T]:
def _sorted_nicely(to_be_sorted: Iterable[_T]) -> List[_T]:
"""Sort the given iterable in the way that humans expect."""
"""Sort the given iterable in the way that humans expect."""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', str(key))]
def convert(text):
 
return int(text) if text.isdigit() else text
 
 
def alphanum_key(key):
 
return [convert(c) for c in re.split('([0-9]+)', str(key))]
 
return sorted(to_be_sorted, key=alphanum_key)
return sorted(to_be_sorted, key=alphanum_key)
@@ -517,7 +522,7 @@ class ProcessCollection:
@@ -517,7 +522,7 @@ class ProcessCollection:
e.g. Jupyter Qt console.
e.g. Jupyter Qt console.
"""
"""
fig, ax = plt.subplots()
fig, ax = plt.subplots()
self.draw_lifetime_chart(ax, show_markers=False)
self.plot(ax, show_markers=False)
f = io.StringIO()
f = io.StringIO()
fig.savefig(f, format="svg")
fig.savefig(f, format="svg")
Loading